Upload
surya-mani
View
218
Download
0
Embed Size (px)
Citation preview
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 1/34
PROGRAM 1
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int dx,dy,x,y,p,x1,y1,x2,y2;
int gd,gm;
clrscr();
printf("Enetr the coordinate of the first point");
scanf("%d%d",&x1,&y1);
printf("Enter the coordinate of second point");
scanf("%d%d",&x2,&y2);
dx=x2-x1;
dy=y2-y1;
p=2*(dy)-(dx);
x=x1;
y=y1;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
putpixel(x,y,WHITE);
while(x<=x2)
{
if(p<0)
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 2/34
{
x=x+1;
y=y;
p=p+2*dy;
}
else
{
x=x+1;
y=y+1;
p=p+2*(dy-dx);
}
putpixel(x,y,WHITE);
}
getch();
closegraph();
}
PROGRAM 2
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,x,y,r;
float x1,y1,p;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 3/34
initgraph(&gd,&gm,"c:\\tc\\bgi");
printf("Enter the center point of the circle");
scanf("%d",&x);
scanf("%d",&y);
scanf("%d",&r);
cleardevice();
x1=0;
y1=r;
p=3-(2*r);
while(x1<=y1)
{
x1=x1+0.1;
if(p<0)
p=p+(4*x1)+6;
else
{
y1=y1-0.1;
p=p+(4*(x1-y1))+10;
}
putpixel(x+x1,y+y1,10);
putpixel(x-x1,y-y1,10);
putpixel(x+x1,y-y1,10);
putpixel(x-x1,y+y1,10);
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 4/34
putpixel(x+y1,y+x1,10);
putpixel(x-y1,y-x1,10);
putpixel(x+y1,y-x1,10);
putpixel(x-y1,y+x1,10);
}
getch();
closegraph();
}
PROGRAME 3
#include<stdio.h>
#include<graphics.h>
#include<math.h>
void main()
{
long d1,d2;
int i,gd,gm,x,y;
long rx,ry,rxsq,rysq,tworxsq,tworysq,dx,dy;
printf("\n Enter the x radius of the ellipse");
scanf("%ld",&rx);
printf("\n Enter the y radius of the ellipse");
scanf("%ld",&ry);
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
rxsq=rx*rx;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 5/34
rysq=ry*ry;
tworxsq=2*rxsq;
tworysq=2*rysq;
x=0;
y=ry;
d1=rysq-rxsq*ry+(0.25*rxsq);
dx=tworysq*x;
dy=tworxsq*y;
do
{
putpixel(200+x,200+y,15);
putpixel(200-x,200-y,15);
putpixel(200+x,200-y,15);
putpixel(200-x,200+y,15);
if(d1<0)
{
x=x+1;
y=y;
dx=dx+tworysq;
d1=d1+dx+rysq;
}
else
{
x=x+1;
y=y-1;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 6/34
dx=dx+tworysq;
dy=dy-tworxsq;
d1=d1+dx-dy+rysq;
}
delay(5);
}
while(dx<dy);
d2=rysq*(x+0.5)*(x+0.5)+rxsq*(y-1)*(y-1)-rxsq*rysq;
do
{
putpixel(200+x,200+y,15);
putpixel(200-x,200-y,15);
putpixel(200+x,200-y,15);
putpixel(200-x,200+y,15);
if(d2>0)
{
x=x;
y=y-1;
dy=dy-tworxsq;
d2=d2-dy+rxsq;
}
else
{
x=x+1;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 7/34
y=y-1;
dy=dy-tworxsq;
dx=dx+tworysq;
d2=d2+dx-dy+rxsq;
}
}
while(y>0);
getch();
closegraph();
}
PROGRAME 4
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
#include<math.h>
#include<dos.h>
#include<stdio.h>
class twodtrans
{
private:
int x1,x2,x3,x4,x5,y1,y2,y3,y4,y5,dx,dy,o,r;
int gd,gm;
float x,y,q,sx,sy;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 8/34
public:
twodtrans();
void box(int x1,int y1,int x2,int y2);
void translation(int a);
void rotation(int b);
void scaling();
};
twodtrans::twodtrans()
{
gd=DETECT;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cout<<"\t\t\t two dimentional transformation\n";
cout<<"\n Enter the left pixel location of the box:";
cin>>x1;
cout<<"\n Enter the top pixel location of the box:";
cin>>y1;
cout<<"\n Enter the right pixel location of the box:";
cin>>x2;
cout<<"\n Enter the bottompixel location of the box:";
cin>>y2;
clrscr();
}
void twodtrans::box(int x1,int y1,int x2,int y2)
{
line(x1,y1,x2,y1);
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 9/34
line(x2,y1,x2,y2);
line(x2,y2,x1,y2);
line(x1,y2,x1,y1);
}
void twodtrans::translation(int a)
{
int rx1,ry1,rx2,ry2;
dx=0;
dy=0;
cout<<"\n Enter the translation in the x axis:";
cin>>dx;
cout<<"\n Enter the translation in the y axis:";
cin>>dy;
clrscr();
if(a==1)
{
rx1=x1+dx;
ry1=y1+dy;
rx2=x2+dx;
ry2=y2+dy;
}
else if(a==2)
{
rx1=x1-dx;
ry1=y1-dy;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 10/34
rx2=x2-dx;
ry2=y2-dy;
}
cleardevice();
outtextxy(220,10,"2D translation");
box(x1,y1,x2,y2);
setcolor(YELLOW);
box(rx1,ry1,rx2,ry2);
setcolor(WHITE);
}
void twodtrans::rotation(int b)
{
cout<<"\n Enter the angle of rotation:";
cin>>r;
for(int i=0;i<=r;i++)
{
cleardevice();
box(x1,y1,x2,y2);
if(b==1)
{
q=(3.14/180)*i;
}
else if(b==2)
{
q=(-1)*(3014/180)*i;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 11/34
}
dx=x2-x1;
dy=y2-y1;
x3=x1+floor((dx)*cos(q));
y3=y1+floor((dx)*sin(q));
x5=x1-floor((dy)*sin(q));
y5=y1+floor((dy)*cos(q));
x4=x5+floor((dx)*cos(q));
y4=y5+floor((dx)*sin(q));
setcolor(YELLOW);
line(x1,y1,x3,y3);
line(x3,y3,x4,y4);
line(x4,y4,x5,y5);
line(x5,y5,x1,y1);
delay(100);
}
setcolor(WHITE);
outtextxy(220,10,"2D rotation");
box(x1,y1,x2,y2);
getch();
cleardevice();
clrscr();
}
void twodtrans::scaling()
{
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 12/34
cout<<"Enter the scaling value:";
sx=0;sy=0;
x=0;y=0;
cin>>sx>>sy;
x=sx*x2;
y=sx*y2;
clrscr();
cleardevice();
outtextxy(220,10,"2D scaling");
box(x1,y1,x2,y2);
setcolor(YELLOW);
box(x1*sx,y1*sy,x2*sx,y2*sy);
setcolor(WHITE);
getch();
}
void main()
{
twodtrans t;
for(;;)
{
cleardevice();
cout<<"\t\t\t two dimentional transformation \n\n";
cout<<"\n\t1.translation\n\t2.rotation\n\t3.scaling\n\t4.exit\n";
int opt,tropt,b;
cin>>opt;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 13/34
switch(opt)
{
case 1:
cout<<"translation\n";
cout<<"1.forward translation\n";
cout<<"2.backward translation\n";
cin>>tropt;
t.translation(tropt);
getch();
break;
case 2:
cout<<"rotation";
cout<<"1.clockwise\n";
cout<<"2.anticlockwise\n";
cin>>b;
t.rotation(b);
break;
case 3:
cout<<"scaling\n";
t.scaling();
break;
case 4:
exit(0);
}
}
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 14/34
}
PROGRAME 5
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<process.h>
class twotrans2
{
private:
int gd,gm;
public:
twotrans2();
void reflect();
void shear();
};
twotrans2::twotrans2()
{
gd=DETECT;
initgraph(&gd,&gm,"c:\\tc\\bgi");
}
void twotrans2::shear()
{
int x,y,j=0,k=0,m,n;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 15/34
char i;
int x1,x2,x3,x4,y1,y2,y3,y4;
clrscr();
cleardevice();
x=640;
y=480;
n=30;
setcolor(15);
rectangle(0,0,x,y);
line(x/2,0,x/2,y);
setcolor(10);
line(x/2-300,y/2+120,x/2-20,y/2+120);
line(x/2-270,y/2+150,x/2-270,y/2-150);
line(x/2+20,y/2+120,x/2-20,y/2+120);
line(x/2+50,y/2+150,x/2+50,y/2-150);
setcolor(15);
outtextxy(x/2-312,y/2+130,"(0,0)");
outtextxy(x/2+8,y/2+130,"(0,0)");
outtextxy(x/2+68,y/2+130,"1");
outtextxy(x/2+98,y/2+130,"2");
outtextxy(x/2+128,y/2+130,"3");
outtextxy(x/2+158,y/2+130,"4");
outtextxy(x/2+188,y/2+130,"5");
outtextxy(x/2+218,y/2+130,"6");
outtextxy(x/2+248,y/2+130,"7");
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 16/34
outtextxy(x/2+278,y/2+130,"8");
outtextxy(x/2-252,y/2+130,"1");
outtextxy(x/2-222,y/2+130,"2");
outtextxy(x/2-192,y/2+130,"3");
outtextxy(x/2-162,y/2+130,"4");
outtextxy(x/2-132,y/2+130,"5");
outtextxy(x/2-102,y/2+130,"6");
outtextxy(x/2-72,y/2+130,"7");
outtextxy(x/2-42,y/2+130,"8");
outtextxy(x/2+18,y/2+98,"1");
outtextxy(x/2+18,y/2+62,"2");
outtextxy(x/2+18,y/2+32,"3");
outtextxy(x/2+18,y/2+2,"4");
outtextxy(x/2+18,y/2-28,"5");
outtextxy(x/2+18,y/2-58,"6");
outtextxy(x/2+18,y/2-88,"7");
outtextxy(x/2+18,y/2-118,"8");
outtextxy(x/2-288,y/2+92,"1");
outtextxy(x/2-288,y/2+62,"2");
outtextxy(x/2-288,y/2+32,"3");
outtextxy(x/2-288,y/2+2,"4");
outtextxy(x/2-288,y/2-28,"5");
outtextxy(x/2-288,y/2-58,"6");
outtextxy(x/2-288,y/2-88,"7");
outtextxy(x/2-288,y/2-118,"8");
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 17/34
getch();
cout<<"\tEnter objects points:";
cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
x1=x/2-270+(x1*n);
x4=x/2-270+(x4*n);
x2=x/2-270+(x2*n);
x3=x/2-270+(x3*n);
y1=y/2+120-(y1*n);
y2=y/2+120-(y2*n);
y3=y/2+120-(y3*n);
y4=y/2+120-(y4*n);
setcolor(14);
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x4,y4);
line(x4,y4,x1,y1);
getch();
j=k=0;
cout<<"\tEnter the shearing ref(x or y):";
cin>>i;
cout<<"\tEnter shearing reference points:";
cin>>j>>k;
cout<<"\t Enter the shearing factor:";
cin>>m;
if((i=='x')||(i=='X'))
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 18/34
{
x1=x1+((x/2)+(j*n));
x2=x2+((x/2)+(j*n));
x3=x3+((x/2)+(j*n)+(n*m));
x4=x4+((x/2)+(j*n)+(n*m));
y1=y1-(k*n);
y2=y2-(k*n);
y3=y3-(k*n);
y4=y4-(k*n);
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x4,y4);
line(x4,y4,x1,y1);
}
if((i=='y')||(i=='Y'))
{
x1=x1+((x/2)+(j*n));
x2=x2+((x/2)+(j*n));
x3=x3+((x/2)+(j*n));
x4=x4+((x/2)+(j*n));
y1=y1-(k*n);
y2=y2-(k*n)-(n*m);
y3=y3-(k*n)-(n*m);
y4=y4-(k*n);
line(x1,y1,x2,y2);
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 19/34
line(x2,y2,x3,y3);
line(x3,y3,x4,y4);
line(x4,y4,x1,y1);
}
getch();
}
void twotrans2::reflect()
{
int x,y,i,j,k,l,m,n,op;
int x1,x2,x3,y1,y2,y3;
clrscr();
cleardevice();
x=640;
y=480;
x1=400;x2=600;x3=500;
y1=200;
y2=200;
y3=60;
setcolor(10);
line(0,y/2,x,y/2);
line(x/2,0,x/2,y);
setcolor(15);
outtextxy(x/2-42,y/2+8,"(0,0)");
outtextxy(x/2-300,y/2-220,"II");
outtextxy(x/2+300,y/2-220,"1");
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 20/34
outtextxy(x/2-300,y/2+220,"III");
outtextxy(x/2+300,y/2+220,"IV");
getch();
setcolor(15);
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
getch();
cout<<"\t Enter your option(2-4):";
cin>>op;
switch(op)
{
case 4:
setcolor(13);
line(x1,y-y1,x2,y-y2);
line(x2,y-y2,x3,y-y3);
line(x3,y-y3,x1,y-y1);
getch();
break;
case 3:
setcolor(11);
line(x-x1,y-y1,x-x2,y-y2);
line(x-x2,y-y2,x-x3,y-y3);
line(x-x3,y-y3,x-x1,y-y1);
getch();
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 21/34
break;
case 2:
setcolor(9);
line(x-x1,y1,x-x2,y2);
line(x-x2,y2,x-x3,y3);
line(x-x3,y3,x-x1,y1);
getch();
break;
}
getch();
}
void main()
{
twotrans2 td;
int opt;
char s='y';
while((s=='y')||(s=='Y'))
{
cout<<"\t 2 dimensional transformation";
cout<<"\t\n\t1.reflection\n\t2.shearing\n\t3.exit\n";
cout<<"\t Enter your option:";
cin>>opt;
switch(opt)
{
case 1:
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 22/34
td.reflect();
cleardevice();
break;
case 2:
td.shear();
cleardevice();
break;
case 3:
exit(0);
}
cout<<"\n\t do you want to continue press 'y'";
cin>>s;
}
closegraph();
}
PROGRAME 6
#include<iostream.h>
#include<dos.h>
#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<graphics.h>
#include<process.h>
int gd=DETECT,gm;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 23/34
double x1,x2,y1,y2;
void draw_cube(double edge[20][3])
{
initgraph(&gd,&gm,"c:\\tc\\bgi");
int i;
clearviewport();
for(i=0;i<19;i++)
{
x1=edge[i][0]+edge[i][2]*(cos(2.3562));
y1=edge[i][1]-edge[i][2]*(sin(2.3562));
x2=edge[i+1][0]+edge[i+1][2]*(cos(2.3562));
y2=edge[i+1][1]-edge[i+1][2]*(sin(2.3562));
line(x1+320,240-y1,x2+320,240-y2);
}
line(320,240,320,25);
line(320,240,550,240);
line(320,240,150,410);
getch();
closegraph();
}
void scale(double edge[20][3])
{
double a,b,c;
int i;
cout<<"\n\t\t\"Enter the scaling factors\":";
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 24/34
cin>>a>>b>>c;
initgraph(&gd,&gm,"c:\\tc\\bgi");
clearviewport();
for(i=0;i<20;i++)
{
edge[i][0]=edge[i][0]*a;
edge[i][1]=edge[i][1]*b;
edge[i][2]=edge[i][2]*c;
}
draw_cube(edge);
closegraph();
getch();
}
void translate(double edge[20][3])
{
int a,b,c;
int i;
cout<<"\n\t\t\"Enter the translating factors\":=";
cin>>a>>b>>c;
initgraph(&gd,&gm,"c:\\tc\\bgi");
clearviewport();
for(i=0;i<20;i++)
{
edge[i][0]+=a;
edge[i][0]+=b;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 25/34
edge[i][0]+=c;
}
draw_cube(edge);
closegraph();
}
void rotate(double edge[20][3])
{
int ch;
int i;
double temp,theta,temp1;
clrscr();
cout<<"\n rotation about";
cout<<"\n\t\t1:==>\"X-axis\"";
cout<<"\n\t\t2:==>\"Y-axis\"";
cout<<"\n\t\t3:==>\"Z-axis\"";
cout<<"\n\t\t\"Enter your choice\":=";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\n\t\t\"Enter the angle\":=";
cin>>theta;
theta=(theta*3.14)/180;
for(i=0;i<20;i++)
{
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 26/34
edge[i][0]=edge[i][0];
temp=edge[i][1];
temp1=edge[i][2];
edge[i][1]=temp*cos(theta)-temp1*sin(theta);
edge[i][2]=temp*sin(theta)+temp1*cos(theta);
}
draw_cube(edge);
break;
case 2:
cout<<"\n\t\t\"Enter the angle\":=";
cin>>theta;
theta=(theta*3.14)/180;
for(i=0;i<20;i++)
{
edge[i][1]=edge[i][1];
temp=edge[i][0];
temp1=edge[i][2];
edge[i][1]=temp*cos(theta)+temp1*sin(theta);
edge[i][2]=temp*sin(theta)+temp1*cos(theta);
}
draw_cube(edge);
break;
case 3:
cout<<"\n enter the angle:";
cin>>theta;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 27/34
theta=(theta*3.14)/180;
for(i=0;i<20;i++)
{
edge[i][2]=edge[i][2];
temp=edge[i][0];
temp1=edge[i][1];
edge[i][1]=temp*cos(theta)-temp1*sin(theta);
edge[i][2]=temp*sin(theta)+temp1*cos(theta);
}
draw_cube(edge);
break;
}
closegraph();
}
void main()
{
int opt;
double
edge[20][3]={40,0,0,40,40,0,0,40,0,0,40,40,0,0,40,0,0,0,40,0,0,40,0,40,40,40,40,0,40,40,40,40,40,40,40,
0,40,40,40,40,40,40,40,40,40,0,40,40,0,40,0,0,0,0,0,0,40,40,0,40};
while(1)
{
clrscr();
cout<<"\n\t\t1:==>\"Draw_cube\"";
cout<<"\n\t\t2:==>\"scaling\"";
cout<<"\n\t\t3:==>\"rotation\"";
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 28/34
cout<<"\n\t\t4:==>\"translation\"";
cout<<"\n\t\t5:==>\"exit\" ";
cout<<"\n\n\t\t\"enter your choice\"";
cin>>opt;
switch(opt)
{
case 1:
draw_cube(edge);
break;
case 2:
scale(edge);
break;
case 3:
rotate(edge);
break;
case 4:
translate(edge);
break;
case 5:
exit(0);
default:
cout<<"\n\t\t\"press a valid key.....!!!!!!\"";
getch();
break;
}
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 29/34
closegraph();
}
}
PROGRAME 7
#include<iostream.h>
#include<dos.h>
#include<stdio.h>
#include<math.h>
#include<conio.h>
#include<graphics.h>
#include<process.h>
int gd=DETECT,gm;
double x1,x2,y1,y2;
void draw_cube(double edge[20][3])
{
initgraph(&gd,&gm,"c:\\tc\\bgi");
int i;
clearviewport();
for(i=0;i<19;i++)
{
x1=edge[i][0]+edge[i][2]*(cos(2.3562));
y1=edge[i][1]-edge[i][2]*(sin(2.3562));
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 30/34
x2=edge[i+1][0]+edge[i+1][2]*(cos(2.3562));
y2=edge[i+1][1]-edge[i+1][2]*(sin(2.3562));
line(x1+320,240-y1,x2+320,240-y2);
}
line(320,240,320,25);
line(320,240,550,240);
line(320,240,150,410);
getch();
closegraph();
}
void reflect(double edge[20][3])
{
int ch;
int i;
clrscr();
cout<<"\n Reflection about";
cout<<"\n\t\t1:==>\"X_AXIS\" ";
cout<<"\n\t\t2:==>\"Y_AXIS\" ";
cout<<"\n\t\t3:==>\"Z_AXIS\" ";
cout<<"\n\t\t\"eNTER YOUR CHOICE\":=";
cin>>ch;
switch(ch)
{
case 1:
for(i=0;i<20;i++)
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 31/34
{
edge[i][0]=edge[i][0];
edge[i][1]=-edge[i][1];
edge[i][2]=-edge[i][2];
}
draw_cube(edge);
break;
case 2:
for(i=0;i<20;i++)
{
edge[i][1]=edge[i][1];
edge[i][0]=-edge[i][0];
edge[i][2]=-edge[i][2];
}
draw_cube(edge);
break;
case 3:
for(i=0;i<20;i++)
{
edge[i][2]=edge[i][2];
edge[i][0]=-edge[i][0];
edge[i][1]=-edge[i][1];
}
draw_cube(edge);
break;
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 32/34
}
closegraph();
}
void main()
{
int opt;
double
edge[20][3]={40,0,0,40,40,0,0,40,0,0,40,40,0,0,40,0,0,0,40,0,0,40,0,40,40,40,40,0,40,40,40,40,40,40,40,
0,40,40,40,40,40,40,40,40,40,0,40,40,0,40,0,0,0,0,0,0,40,40,0,40};
while(1)
{
clrscr();
cout<<"\n\t\t1:==>\"draw_cube\" ";
cout<<"\n\t\t2:==>\"reflection\" ";
cout<<"\n\t\t3:==>\"exit\" ";
cout<<"\n\t\t\"enter your option\" ";
cin>>opt;
switch(opt)
{
case 1:
draw_cube(edge);
break;
case 2:
reflect(edge);
break;
case 3:
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 33/34
exit(0);
default:
cout<<"\n\t\t\"press a valid key.............!!!!!!!!!!\" ";
getch();
break;
}
closegraph();
}
}
8/3/2019 CG PROGRAME 33
http://slidepdf.com/reader/full/cg-programe-33 34/34