编程论坛's Archiver

api618 发表于 2007-1-15 20:08

[求助]用C语言实现的二维图形的变换-->nuciewth转移

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

神秘失恋 发表于 2007-1-16 00:37

[em13]<BR><BR>怎么发到这来了?[em03]

nuciewth 发表于 2007-1-16 16:53

估计这样的格式你自己都不愿看吧.[em03]<BR>图形编程,我不懂,我帮你转到图形专区去吧.

api618 发表于 2007-1-16 20:04

<P>是啊 ,没注释,很难去看</P>

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.