图形学题目求助
请大家帮忙看看这三个程序有没有问题???1。编程:画出从0—360度角的sin值的变化
#include <stdio.h>
#include <graphics.h>
#include <math.h>
#define PI 3.1415926
void main()
{
int driver=DETECT,mode,i;
double x1,y1,m,x2,y2;
initgraph( &driver, &mode,"c:\\tc");
//绘制坐标
line(150,180,150,360);
line(100,300,400,300);
line(150,180,145,190);
line(150,180,155,190);
line(400,300,390,305);
line(400,300,390,295);
//输出正弦函数,其中原点为(150,300)
for(i=0;i<=360;i++)
{
m=i/360.0*(2*PI);
x2=150+m*30;
y2=300-sin(m)*30;
putpixel(x2,y2,5);
}
getch();
closegraph();
}
2。画出任意形状的立方体
#include <stdio.h>
#include <graphics.h>
void main()
{
int driver=DETECT,mode,p=20;
double x1=300,y1=200,m,x2=400,y2=300,radius=100;
printf("please");
initgraph( &driver, &mode,"c:\\tc");
//绘制两个正方形
rectangle(x1,y1,x2,y2);
rectangle(x1+p,y1+p,x2+p,y2+p);
//将两个正方形用短线连接起来,组成立方体
moveto(x1,y1);
linerel(p,p);
moveto(x1+radius,y1);
linerel(p,p);
moveto(x1+radius,y1+radius);
linerel(p,p);
moveto(x1,y1+radius);
linerel(p,p);
getch();
closegraph();
}
3。画出扇形
#include <stdio.h>
#include <graphics.h>
#include <math.h>
#define PI 3.1415926
void main()
{
int driver=DETECT,mode,stangle=60,endangle=120,x=300,y=240;
double radius=200;
initgraph( &driver, &mode,"d:\\tc");
line(0,240,639,240);//设置标准线
//以(x,y)为圆心,radius为半径,起始角度为stangle,中止角度为endangle,半径为radius画弧
arc(x,y,stangle,endangle,radius);
//绘制扇形的两条半径
moveto(300,240);
linerel(100,-(sin(60*PI/180)*radius));
moveto(300,240);
linerel(-100,-(sin(60*PI/180)*radius));
getch();
closegraph();
}