-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path3D Transformation
81 lines (78 loc) · 1.37 KB
/
3D Transformation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
11. 3D Transformation
//3D transformation
#include<stdio.h>
#include<iostream.h>
#include<dos.h>
#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
void main()
{
intgd=DETECT,gm;
intans=0;
while(ans!=4)
{
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
cleardevice();
cout<<"\n--------------Welcome to The Program--------------\n";
cout<<"\n1. Translation";
cout<<"\n2. Scaling";
cout<<"\n3. Rotation";
cout<<"\n4. Exit";
cout<<"\n\nEnter your choice : ";
cin>>ans;
sleep(2);
cleardevice();
intymax,xmax;
xmax=getmaxx();
ymax=getmaxy();
intxm,ym;
xm=xmax/2;
ym=ymax/2;
setcolor(RED);
bar3d(100,200,190,130,15,1);
xmax=getmaxx();
ymax=getmaxy();
intxmid=xmax/2;
intymid=ymax/2;
setcolor(GREEN);
line(0,ymid,xmax,ymid);
line(xmid,0,xmid,ymax);
if(ans==1)
{
inttx,ty;
outtextxy(0,0,"\n enter transaction factor \n");
cin>>tx>>ty;
bar3d(100+tx,200+ty,190+tx,130+ty,15,1);
sleep(5);
}
else if (ans==2)
{
intsx,sy;
outtextxy(0,0,"\n enter scalling factor \n");
cin>>sx>>sy;
bar3d((100*sx),(20*sy),(90*sx),(60*sy),20,5);
sleep(5);
}else if(ans==3)
{
int t;
outtextxy(0,0,"\n enter angle \n");
cin>>t;
t=t*(3.14/180);
int x1=((100*cos(t))-(20*sin(t)));
int y1=((100*sin(t))+(20*cos(t)));
int x2=((90*cos(t))-(60*sin(t)));
int y2=((90*sin(t))+(60*cos(t)));
bar3d(x1,y1,x2,y2,20,5);
sleep(5);
}
else if(ans==4)
exit(1);
else
{
outtextxy(50,50,"\n\nEnter a valid choice : ");
}
}
getch();
}