pradeep | Date: Tuesday, 11 February 14, 10:08 PM | Message # 1 |
![pradeep](/avatar/43/8297-835322.jpg) pk
Group: Administrators
Messages: 82
Status: Offline
| Code #include"3dframe.cpp" #include<iostream.h> void circleMidpoint(int ,int ,int,int ); void circlePlotpoint(int ,int ,int ,int,int ) ; void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\tc\\bgi"); int x_center=0,y_center=0,z_center=0,radius=700; DRAW3DFRAME(); cleardevice(); outtextxy(0,0,"Circle before Sweep"); circleMidpoint(x_center,y_center,z_center,radius); getch(); outtextxy(0,50,"Now look at the Translational Sweep"); getch(); for(int i=0;i<=1000;i=i+1) { translate_point(x_center,y_center,z_center,0,0,1); x_center=P1[0][0]; y_center=P1[0][1]; z_center=P1[0][2]; circleMidpoint(P1[0][0],P1[0][1],P1[0][2],radius); } getch(); cleardevice(); moveto(0,0); outtextxy(0,0,"Now look at the Rotational Sweep"); getch(); cleardevice(); radius=200; for(float j=0;j<=360;j=j+1) { rotate_point_X(x_center,y_center,z_center,j); x_center=P1[0][0]; y_center=P1[0][1]; z_center=P1[0][2]; circleMidpoint(P1[0][0],P1[0][1],P1[0][2],radius); } getch(); cleardevice(); outtextxy(0,0,"Now look at another the Rotational Sweep"); getch(); cleardevice(); radius=1500; for( i=0;i<=300;i=i+1) { rotate_point_X(-x_center,-y_center,-z_center,-1); x_center=P1[0][0]; y_center=P1[0][1]; z_center=P1[0][2]; circleMidpoint(P1[0][0],P1[0][1],P1[0][2],radius); rotate_point_Y(-x_center,-y_center,-z_center,-1); x_center=P1[0][0]; y_center=P1[0][1]; z_center=P1[0][2]; circleMidpoint(P1[0][0],P1[0][1],P1[0][2],radius); rotate_point_Z(-x_center,-y_center,-z_center,-1); x_center=P1[0][0]; y_center=P1[0][1]; z_center=P1[0][2]; circleMidpoint(P1[0][0],P1[0][1],P1[0][2],radius); } getch(); cleardevice(); getch(); closegraph(); } void circleMidpoint(int xcenter,int ycenter,int zcenter,int radius) { int x=0; int y=radius; int p=1-radius; //plot for first set of points circlePlotpoint(xcenter,ycenter,zcenter,x,y); while(x<y) { x=x+1; if(p<0) p += 2*x + 1; else { y=y-1; p +=2*(x-y)+1; } circlePlotpoint(xcenter,ycenter,zcenter,x,y); } } void circlePlotpoint(int xcenter,int ycenter,int zcenter,int x,int y) { int arr[4]; putxyz(xcenter+x,ycenter+y,zcenter,arr,RED); putxyz(xcenter-x,ycenter+y,zcenter,arr,LIGHTRED); putxyz(xcenter+x,ycenter-y,zcenter,arr,MAGENTA); putxyz(xcenter-x,ycenter-y,zcenter,arr,BROWN); putxyz(xcenter+y,ycenter+x,zcenter,arr,BLUE); putxyz(xcenter-y,ycenter+x,zcenter,arr,YELLOW); putxyz(xcenter+y,ycenter-x,zcenter,arr,GREEN); putxyz(xcenter-y,ycenter-x,zcenter,arr,LIGHTGREEN); }
|
|
| |