[Math] Calculate the angle of a vector in compass (360) direction

trigonometry

Given a vector described by X and Y components

$x=4$

$ y=-2$

I get the direction of the vector by using $\arctan{-\frac 24}$.

$\theta= -0.4636 \text{ rad}$

$\theta= -26.565^{\circ}$

My initial confusion was that I assumed the degrees in theta referred to a compass direction as would be measured with a protractor. But a vector of 4,-2 ends up in the 2nd quadrant somewhere between 90 and 180, so I know -26 is not my true compass direction of the vector.

So my question is, how do you convert the theta direction of a vector to a compass bearing (0-360 degrees)

Best Answer

If you are working solely in degrees, the following equation will transform your angle from polar coordinates (0 at x, 0 going CCW) to compass angle (0 at 0, y going CW)

(450 - θ) % 360

where % is the modulus function