Line | |
---|
1 | #include <cmath> |
---|
2 | //#include <iostream.h> |
---|
3 | |
---|
4 | int main(){ |
---|
5 | |
---|
6 | int dirX, dirY, dirZ; //flying direction |
---|
7 | int ortX, ortY, ortZ; //orthogonal direction |
---|
8 | int dX, dY, dZ; //distance between main ship and the object |
---|
9 | int vecX, vecY, vecZ; //vector product dir X ort |
---|
10 | double alpha; //defines the radius in the radar |
---|
11 | double beta; //defines the angle in the radar |
---|
12 | bool right; //checks whether the object is on the right side (since cos is not bijective) |
---|
13 | |
---|
14 | dirX = 1; |
---|
15 | dirY = 0; |
---|
16 | dirZ = 0; |
---|
17 | |
---|
18 | ortX = 0; |
---|
19 | ortY = 0; |
---|
20 | ortZ = 1; |
---|
21 | |
---|
22 | dX = 2; |
---|
23 | dY = 0; |
---|
24 | dZ = 0; |
---|
25 | |
---|
26 | alpha = acos(((double)(dirX*dX+dirY*dY+dirZ*dZ))/(sqrt((double)(pow(dX,2)+pow(dY,2)+pow(dZ,2)))+sqrt((double)(pow(dirX,2)+pow(dirY,2)+pow(dirZ,2))))); |
---|
27 | beta = acos(((double)(ortX*dX+ortY*dY+ortZ*dZ))/(sqrt((double)(pow(dX,2)+pow(dY,2)+pow(dZ,2)))+sqrt((double)(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2))))); |
---|
28 | vecX = dirY*ortZ - dirZ*ortY; |
---|
29 | vecY = dirZ*ortX - dirX*ortZ; |
---|
30 | vecZ = dirX*ortY - dirY*ortX; |
---|
31 | |
---|
32 | if((vecX*dX+vecY*dY+vecZ*dZ)>0){right=true;} |
---|
33 | else right=false; |
---|
34 | |
---|
35 | // cout<<alpha; |
---|
36 | // cout<<beta; |
---|
37 | |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | |
---|
Note: See
TracBrowser
for help on using the repository browser.