| | 33 | |
| | 34 | '''Calculating Exact Positions:''' |
| | 35 | |
| | 36 | Because the radar command returns only relative values based on the quagent's current orientation, a little additional work is required to find the absolute position of the object (this is useful if the user would prefer to use a [[mt]] rather than a [[mb]] command). Say the radar responds, "rs ra 512 2 ammo_shells 300.00 81.00 31.00". This means that the shells are 300 units away at relative yaw 81 and relative pitch 31. To calculate the point to issue a [[mt]] command with, the vertical component of the distance must be removed (D=D*cos(pitch)), and then the absolute position calculated. This is simple trigonometry: |
| | 37 | {{{ |
| | 38 | D = 300; //responded distance |
| | 39 | W = 81; //responded yaw |
| | 40 | P = 31; //responded pitch |
| | 41 | F = 45; //agent's current yaw |
| | 42 | I = -15; //agent's current pitch |
| | 43 | X = 0; //agent's current location (x) |
| | 44 | Y = 0; //agent's current location (y) |
| | 45 | |
| | 46 | L = D * cos(P + I); |
| | 47 | X' = X + L * cos(W + F); //absolute position of target (x) |
| | 48 | Y' = Y + L * sin(W + F); //absolute position of target (y) |
| | 49 | }}} |
| | 50 | |
| | 51 | [[Image(radarcompdemo.png)]] |