DontTouchTheClock wrote:If anyone has watched Star-Trek, they may know of the bearing system used. IF not:
Azimuth is for "horizontal bearing" (x,z)
Elevation is for "vertical bearing" (y)
Thus if a player is at (7,8,9) and heads for a (45*,45*) bearing for 1.414, they will reach (8,9,10).
My question is this, if I am at (9,6,5) how would I get to (3,3,3)?
Also, how would I find the result location from Azimuth, Elevation and Distance?
I like to break these type of problems down into simple geometry.
cos a = opposite / hypotenuse
sin a = adjacent / hypotenuse
tan a = opposite / adjacent
for the length of the opposite I usually pick the vertical: 6 - 3 = -3
to get the length of the horizontal we use pythagoras: sqrt((9 - 3)^2 + (5 - 3)^2) = sqrt(40) = 6.325
now we can establish the vertical bearing angle: tan V = -3 / 6.325 -> V = -129.4 (which is the inverse direction of 39 degrees up/right, so it's down and left)
The horizontal angle is a bit easier, since the sides length doesn't require two steps to calculate.
The horizontal sides are (9-3) and (5-3) long. So the vector is -6, 0, -2. tan V = -2 / -6 -> V = 18.43.
Of course we're in the 3rd quadrant so the actual heading is 180+18.43 = 198.43.
DISCLAIMER: this was entirely off the top off my head. May contain errors.