计算机图形学TC编程
请懂计算机图形学的友友帮帮忙帮我编写一个能在TC2.0上运行的程序代码要求:稍微简单一点的动态图形就好我学的课本是中国水利水电出版社的计算机图形学请友友们帮忙用用心要自己...
请懂计算机图形学的友友帮帮忙 帮我编写一个能在TC2.0上运行的程序代码
要求:
稍微简单一点的动态图形就好 我学的课本是中国水利水电出版社的计算机图形学
请友友们帮忙 用用心 要自己编写的哦
一楼的那个在TC2.0上运行有错误 展开
要求:
稍微简单一点的动态图形就好 我学的课本是中国水利水电出版社的计算机图形学
请友友们帮忙 用用心 要自己编写的哦
一楼的那个在TC2.0上运行有错误 展开
2个回答
展开全部
#include "graphics.h"
#include "math.h"
void circlepoints(int x,int y,int a,int b)
{ putpixel(x+a,y+b,6);
putpixel(-x+a,y+b,6);
putpixel(x+a,-y+b,6);
putpixel(-x+a,-y+b,6);
}
void circlepoints1(int x,int y,float f)
{
putpixel((x+200-250)*cos(f)-(y+150-200)*sin(f)+250,(x+200-250)*sin(f)+(y+150-200)*cos(f)+200,2);
putpixel((-x+200-250)*cos(f)-(y+150-200)*sin(f)+250,(-x+200-250)*sin(f)+(y+150-200)*cos(f)+200,2);
putpixel((x+200-250)*cos(f)-(-y+150-200)*sin(f)+250,(x+200-250)*sin(f)+(-y+150-200)*cos(f)+200,2);
putpixel((-x+200-250)*cos(f)-(-y+150-200)*sin(f)+250,(-x+200-250)*sin(f)+(-y+150-200)*cos(f)+200,2);
}
void dda(int a,int b,float k,float l)
{
float dy,dx,y,m,j,x;
dx=100;
dy=0;
m=dy/dx;
y=50;
for(x=50;x<=150;x++)
{
x=(x-a)*k-(y-b)*l+a;
j=(x-a)*l+(y-b)*k+b;
putpixel((int)x,(int)j,2);
y+=m;
}
}
/*void circle1(int x,int y,int r)
{
int a,b;
float d;
a=0;b=r;
d=5.0/4-r;
putpixel(a+x,b+y,2);
while(b>a)
{ if(d<=0)
d+=2.0*a+3;
else
{ d+=2.0*(a-b)+50;
b--;
}
a++;
putpixel(a+x,b+y,2);
}
} */
/*void ar(int a,int b)
{
int x,y,d;
x=0;
y=50;
circlepoints(x,y,a,b);
x=1;
circlepoints(x,y,a,b);
while (y>=0)
{ if(d>=0)
{ d=d-2*y+1;
y--;}
else
{d=d+2*x+1;
x++;
}
circlepoints(x,y,a,b);
}
}*/
void main()
{ int driver=DETECT,mode; int x,y,d,a=100,b=50,t=5;
float k,l,f;
registerbgidriver(EGAVGA_driver);
initgraph(&driver,&mode,"\\tc"); /* 对于svga256必需执行该函数以安装BGI驱动 */
initgraph(&driver,&mode,"\\tc"); /* 执行TC默认的BGI初始化函数 */
while(!kbhit())
{ if((b==430)&&(t==5))t=-5;
if((b==50)&&(t==-5))t=5;
b+=t;
x=0;
y=50;
circlepoints(x,y,a,b);
x=1;
circlepoints(x,y,a,b);
while (y>=0)
{ if(d>=0)
{ d=d-2*y+1;
y--;}
else
{d=d+2*x+1;
x++;
}
circlepoints(x,y,a,b);
}
if(f=3.14159) f=0;
f+=0.00001;
x=0;
y=30;
circlepoints1(x,y,f);
x=1;
circlepoints1(x,y,f);
while (y>=0)
{ if(d>=0)
{ d=d-2*y+1;
y--;}
else
{d=d+2*x+1;
x++;
}
circlepoints1(x,y,f);
}
delay(5000);
if(f=3.14159) f=0;
f+=0.00001;
circle((200-250)*cos(f)-(150-200)*sin(f)+250,(200-250)*sin(f)+(150-200)*cos(f)+200,20);
cleardevice();
}
getch();
closegraph();
}
#include "math.h"
void circlepoints(int x,int y,int a,int b)
{ putpixel(x+a,y+b,6);
putpixel(-x+a,y+b,6);
putpixel(x+a,-y+b,6);
putpixel(-x+a,-y+b,6);
}
void circlepoints1(int x,int y,float f)
{
putpixel((x+200-250)*cos(f)-(y+150-200)*sin(f)+250,(x+200-250)*sin(f)+(y+150-200)*cos(f)+200,2);
putpixel((-x+200-250)*cos(f)-(y+150-200)*sin(f)+250,(-x+200-250)*sin(f)+(y+150-200)*cos(f)+200,2);
putpixel((x+200-250)*cos(f)-(-y+150-200)*sin(f)+250,(x+200-250)*sin(f)+(-y+150-200)*cos(f)+200,2);
putpixel((-x+200-250)*cos(f)-(-y+150-200)*sin(f)+250,(-x+200-250)*sin(f)+(-y+150-200)*cos(f)+200,2);
}
void dda(int a,int b,float k,float l)
{
float dy,dx,y,m,j,x;
dx=100;
dy=0;
m=dy/dx;
y=50;
for(x=50;x<=150;x++)
{
x=(x-a)*k-(y-b)*l+a;
j=(x-a)*l+(y-b)*k+b;
putpixel((int)x,(int)j,2);
y+=m;
}
}
/*void circle1(int x,int y,int r)
{
int a,b;
float d;
a=0;b=r;
d=5.0/4-r;
putpixel(a+x,b+y,2);
while(b>a)
{ if(d<=0)
d+=2.0*a+3;
else
{ d+=2.0*(a-b)+50;
b--;
}
a++;
putpixel(a+x,b+y,2);
}
} */
/*void ar(int a,int b)
{
int x,y,d;
x=0;
y=50;
circlepoints(x,y,a,b);
x=1;
circlepoints(x,y,a,b);
while (y>=0)
{ if(d>=0)
{ d=d-2*y+1;
y--;}
else
{d=d+2*x+1;
x++;
}
circlepoints(x,y,a,b);
}
}*/
void main()
{ int driver=DETECT,mode; int x,y,d,a=100,b=50,t=5;
float k,l,f;
registerbgidriver(EGAVGA_driver);
initgraph(&driver,&mode,"\\tc"); /* 对于svga256必需执行该函数以安装BGI驱动 */
initgraph(&driver,&mode,"\\tc"); /* 执行TC默认的BGI初始化函数 */
while(!kbhit())
{ if((b==430)&&(t==5))t=-5;
if((b==50)&&(t==-5))t=5;
b+=t;
x=0;
y=50;
circlepoints(x,y,a,b);
x=1;
circlepoints(x,y,a,b);
while (y>=0)
{ if(d>=0)
{ d=d-2*y+1;
y--;}
else
{d=d+2*x+1;
x++;
}
circlepoints(x,y,a,b);
}
if(f=3.14159) f=0;
f+=0.00001;
x=0;
y=30;
circlepoints1(x,y,f);
x=1;
circlepoints1(x,y,f);
while (y>=0)
{ if(d>=0)
{ d=d-2*y+1;
y--;}
else
{d=d+2*x+1;
x++;
}
circlepoints1(x,y,f);
}
delay(5000);
if(f=3.14159) f=0;
f+=0.00001;
circle((200-250)*cos(f)-(150-200)*sin(f)+250,(200-250)*sin(f)+(150-200)*cos(f)+200,20);
cleardevice();
}
getch();
closegraph();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询