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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int rotx, roty, rotz, n, ac1, ac2, ac3, ac4, atransx, atransy, atransz;
double axx1, ayx1, azx1, axy1, ayy1, azy1, axz1, ayz1, azz1;
int transx=0;
int transy=0;
int transz=0;
int c1=0;
int c2=0;
int c3=0;
int c4=1;
int counter;
int count=0;
char command;
Start:
float xx1 = 0;
float yx1 = 0;
float zx1 = 0;
float xy1 = 0;
float yy1 = 0;
float zy1 = 0;
float xz1 = 0;
float yz1 = 0;
float zz1 = 0;
cout<<"Choose a command (Maximum of 3 Operations):"<<endl;
cout<<"[1] Rotate X"<<endl<<"[2] Rotate Y"<<endl<<"[3] Rotate Z"<<endl<<"[4] Add Transformation"<<endl<<"[6] Calculate"<<endl<<"[7] Quit"<<endl<<"Choice: ";
cin>>n;
switch (n){
case 1:
cout <<"Rotate X at angle: "<<endl;
cin >> rotx;
xx1 = sin (rotx*3.14/180);
yx1 = cos (rotx*3.14/180);
zx1 = cos (rotx*3.14/180);
xy1 = cos (rotx*3.14/180);
yy1 = cos (rotx*3.14/180);
zy1 = sin (rotx*3.14/180);
xz1 = cos (rotx*3.14/180);
yz1 = -sin (rotx*3.14/180);
zz1 = cos (rotx*3.14/180);
count=count+1;
cout<<"Angle included"<<endl<<endl;
goto Input;
break;
case 2:
cout<<"Rotate Y at angle: "<<endl;
cin >> roty;
xx1 = cos (roty*3.14/180);
yx1 = cos (roty*3.14/180);
zx1 = -sin (roty*3.14/180);
xy1 = cos (roty*3.14/180);
yy1 = sin (roty*3.14/180);
zy1 = cos (roty*3.14/180);
xz1 = sin (roty*3.14/180);
yz1 = cos (roty*3.14/180);
zz1 = cos (roty*3.14/180);
count++;
cout<<"Angle included"<<endl<<endl;
goto Input;
break;
case 3:
cout <<"Rotate Z at angle: "<<endl;
cin >> rotz;
xx1 = cos (rotz*3.14/180);
yx1 = sin (rotz*3.14/180);
zx1 = cos (rotz*3.14/180);
xy1 = -sin (rotz*3.14/180);
yy1 = cos (rotz*3.14/180);
zy1 = cos (rotz*3.14/180);
xz1 = cos (rotz*3.14/180);
yz1 = cos (rotz*3.14/180);
zz1 = sin (rotz*3.14/180);
count++;
cout<<"Angle included"<<endl<<endl;
goto Input;
break;
} //end of cases
Input:
if (count==1)
{
axx1=xx1;
ayx1=yx1;
azx1=zx1;
ac1=c1;
axy1=xy1;
ayy1=yy1;
azy1=zy1;
ac2=c2;
axz1=xz1;
ayz1=yz1;
azz1=zz1;
ac3=c3;
atransx=transx;
atransy=transy;
atransz=transz;
ac4=c4;
cout<<"Your Translation is:"<<endl<<endl;
cout<<" "<<axx1<<" "<<axy1<<" "<<axz1<<" "<<atransx<<" "<<endl;
cout<<" "<<ayx1<<" "<<ayy1<<" "<<ayz1<<" "<<atransy<<" "<<endl;
cout<<" "<<azx1<<" "<<azy1<<" "<<azz1<<" "<<atransz<<" "<<endl;
cout<<" "<<ac1<<" "<<ac2<<" "<<ac3<<" "<<ac4<<" "<<endl<<endl<<endl;
goto Start;
}
else
return 0;
}
|