martin@0
|
1 #include <iostream>
|
martin@0
|
2 #include "Decoder.h"
|
martin@0
|
3 #include <cmath>
|
martin@0
|
4 using namespace std;
|
martin@0
|
5
|
martin@0
|
6 int main (int argc, char * const argv[]) {
|
martin@0
|
7 string answer;
|
martin@0
|
8 int test_choice;
|
martin@0
|
9
|
martin@0
|
10 do{
|
martin@0
|
11
|
martin@0
|
12 double azimuth, elevation;
|
martin@0
|
13 Decoder myDecoder;
|
martin@0
|
14
|
martin@0
|
15
|
martin@0
|
16
|
martin@0
|
17 cout << "Provide Azimuth then Elevation\n";
|
martin@0
|
18 cin >> azimuth >> elevation;
|
martin@0
|
19
|
martin@0
|
20 double w_in = 1/sqrt(2);
|
martin@0
|
21 double x_in = cos(myDecoder.degRad(azimuth)) * cos(myDecoder.degRad(elevation));
|
martin@0
|
22 double y_in = sin(myDecoder.degRad(azimuth)) * cos(myDecoder.degRad(elevation));
|
martin@0
|
23 double z_in = sin(myDecoder.degRad(elevation));
|
martin@0
|
24
|
martin@0
|
25
|
martin@0
|
26 cout << endl << "w_in = " << w_in << endl;
|
martin@0
|
27 cout << "x_in = " << x_in << endl;
|
martin@0
|
28 cout << "y_in = " << y_in << endl;
|
martin@0
|
29 cout << "z_in = " << z_in << endl << endl;
|
martin@0
|
30
|
martin@0
|
31 cout << "Selection\n 1=Rotation\n 2=Tilt\n 3=Tumble\n 4=Dominance\n 5=Press\n 6=Push\n 7=Focus\n 8=xyDecode\n 9=msDecode\n";
|
martin@0
|
32 cin >> test_choice;
|
martin@0
|
33
|
martin@0
|
34
|
martin@0
|
35 switch (test_choice) {
|
martin@0
|
36 case 1:
|
martin@0
|
37 //Test Rotation
|
martin@0
|
38 cout << "Enter rotation in degrees:\n";
|
martin@0
|
39 cin >> myDecoder.Rotate;
|
martin@0
|
40 myDecoder.rotateField(x_in, y_in);
|
martin@0
|
41 break;
|
martin@0
|
42 case 2:
|
martin@0
|
43 //Test Tilt
|
martin@0
|
44 cout << "Enter tilt in degrees:\n";
|
martin@0
|
45 cin >> myDecoder.Tilt;
|
martin@0
|
46 myDecoder.tiltField(y_in, z_in);
|
martin@0
|
47 break;
|
martin@0
|
48 case 3:
|
martin@0
|
49 //Test Tumble
|
martin@0
|
50 cout << "Enter tumble in degrees:\n";
|
martin@0
|
51 cin >> myDecoder.Tumble;
|
martin@0
|
52 myDecoder.tumbleField(x_in, z_in);
|
martin@0
|
53 break;
|
martin@0
|
54 case 4:
|
martin@0
|
55 //Test Tumble
|
martin@0
|
56 cout << "Enter Zoom factor, -100 to 100:\n";
|
martin@0
|
57 cin >> myDecoder.Zoom;
|
martin@0
|
58 myDecoder.dominanceZoom(w_in, x_in, y_in, z_in);
|
martin@0
|
59 break;
|
martin@0
|
60 case 5:
|
martin@0
|
61 //Test Press
|
martin@0
|
62 cout << "Enter Zoom factor, -100 to 100:\n";
|
martin@0
|
63 cin >> myDecoder.Zoom;
|
martin@0
|
64 myDecoder.pressZoom(w_in, x_in, y_in, z_in);
|
martin@0
|
65 break;
|
martin@0
|
66 case 6:
|
martin@0
|
67 //Test Push
|
martin@0
|
68 cout << "Enter Zoom factor, -100 to 100:\n";
|
martin@0
|
69 cin >> myDecoder.Zoom;
|
martin@0
|
70 myDecoder.pushZoom(w_in, x_in, y_in, z_in);
|
martin@0
|
71 break;
|
martin@0
|
72 case 7:
|
martin@0
|
73 //Test Focus
|
martin@0
|
74 cout << "Enter Zoom factor, -100 to 100:\n";
|
martin@0
|
75 cin >> myDecoder.Zoom;
|
martin@0
|
76 myDecoder.focusZoom(w_in, x_in, y_in, z_in);
|
martin@0
|
77 break;
|
martin@0
|
78 case 8:
|
martin@0
|
79 //Stereo Decode XY
|
martin@0
|
80 cout << "Enter Width and Pattern\n";
|
martin@0
|
81 cin >> myDecoder.Width >> myDecoder.Pattern;
|
martin@0
|
82 myDecoder.xyDecode(w_in, x_in, y_in, z_in);
|
martin@0
|
83 break;
|
martin@0
|
84 case 9:
|
martin@0
|
85 //Stereo Decode MS
|
martin@0
|
86 cout << "Enter Width and Pattern\n";
|
martin@0
|
87 cin >> myDecoder.Width >> myDecoder.Pattern;
|
martin@0
|
88 myDecoder.msDecode(w_in, x_in, y_in, z_in);
|
martin@0
|
89 break;
|
martin@0
|
90
|
martin@0
|
91
|
martin@0
|
92
|
martin@0
|
93
|
martin@0
|
94 default:
|
martin@0
|
95 break;
|
martin@0
|
96 }
|
martin@0
|
97
|
martin@0
|
98
|
martin@0
|
99
|
martin@0
|
100
|
martin@0
|
101
|
martin@0
|
102
|
martin@0
|
103 cout << endl << "w new = " << w_in << endl;
|
martin@0
|
104 cout << "x new = " << x_in << endl;
|
martin@0
|
105 cout << "y new = " << y_in << endl;
|
martin@0
|
106 cout << "z new = " << z_in << endl;
|
martin@0
|
107
|
martin@0
|
108
|
martin@0
|
109 double azimuth_out = atan2(y_in, x_in);
|
martin@0
|
110 double elevation_out = atan2(z_in, sqrt(pow(x_in,2) + pow(y_in,2)));
|
martin@0
|
111 cout << endl << "Calculate azimuth = " << myDecoder.radDeg(azimuth_out) <<endl;
|
martin@0
|
112 cout << "Calculate elevation = " << myDecoder.radDeg(elevation_out) <<endl;
|
martin@0
|
113
|
martin@0
|
114 if (test_choice==8 || test_choice==9) {
|
martin@0
|
115 cout << endl << "Output Left = " << myDecoder.outputL;
|
martin@0
|
116 cout << endl << "Output Right = " << myDecoder.outputR <<endl;
|
martin@0
|
117 }
|
martin@0
|
118
|
martin@0
|
119 cout << endl << "Repeat? y for yes.\n";
|
martin@0
|
120 cin >> answer;
|
martin@0
|
121 cout << endl;
|
martin@0
|
122 } while(answer == "y");
|
martin@0
|
123
|
martin@0
|
124 return 0;
|
martin@0
|
125 }
|