效果为一三角形绕一点旋转一周,下面程序应如何修改,请高手指点
#include"graphics.h"
#include"math.h"
#define PAI 3.14159265
void fdw(float m[][3])
{unsigned count;
for(count=0;count<3;count++)
{m[count][0]=0;m[count][1]=0;
m[count][2]=0;m[count][count]=1;
}}
void mm2(float ma[][3],float mb[][3],float mc[][3])
{int i,j,k;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{mc[i][j]=0;
for(k=0;k<3;k++);
mc[i][j]=mc[i][j]+ma[i][k]*mb[k][j];}}
pallel(float x,float y,float p[3][3])
{fdw(p);p[2][0]=x;p[2][1]=y;}
rotate(float c1,float p[3][3])
{c1=PAI/180*c1;fdw(p);
p[0][0]=cos(c1);p[0][1]=sin(c1);
p[1][0]=-sin(c1);p[1][1]=cos(c1);}
affinex(float x,float y,float t[3][3])
{float xx; xx=x*t[0][0]*y*t[1][0]*t[2][0];
return xx;}
scx(float xi)
{float x;
x=xi+getmaxx()/2;
return(x);
}
scy(float yi)
{float y;
y=yi+getmaxy()/2;
return(y);}
main()
{int i,c=13;
float x=120,y=-50;
float x1[]={120,200,250,120};
float y1[]={70,70,30,70};
float x2[4];
float y2[4];
float t1[3][3],t2[3][3],t3[3][3],m1[3][3],m2[3][3];
float c1=30;
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
getch();
setcolor(RED);
line(getmaxx()/2,0,getmaxx()/2,getmaxy());
getch();
line(0,getmaxy()/2,getmaxx()/2,getmaxx());
getch();
putpixel(scx(x),scy(y),GREEN);
setcolor(YELLOW);
circle(scx(x),scy(y),3);
getch();
while (c1<=360)
{setcolor(c);
pallel(-x,-y,t1);
rotate(c1,t2);
pallel(x,y,t3);
mm2(t1,t2,m1);
mm2(m1,t3,m2);
for(i=0;i<=3;i++)
{x2[i]=affinex(x1[i],y1[i],m2);
y2[i]=affinex(x1[i],y1[i],m2);
}
}}