How do I convert a line angle to a navigational-bearing scale (i.e., with range of [0,360] with “North” = 0 deg)? I have two points, (x1,y1) and (x2,y2),  that I'd like to draw a line between. I know I can figure out the angle of that line using Sin(th)=opp/Hyp:
theta = arcsin((y1-y2)/sqrt((y1-y2)^2 + (x1-x2)^2))) *180/pi
or by using arctangent and the slope:
theta = arctan((y2-y1)/(x2-x1)) * 180/pi
However, I want to convert that angle to be on the scale of [0,360]. 
Basically, I want my angle to be on a compass scale in which "North" is 0 deg, "East" is 90 deg, "South" is 180 deg, and "West" is 270 deg . 
Thanks!!
 A: Here is a way to get a direction angle for your line, where $0\le \theta<180°$, $0°$ means straight up (due north), and $90°$ means to the right (due east). This is the standard for bearings in navigation. Let me know if you mean something else: your comments have not been clear.
$$\theta = \begin{cases}
90°-\dfrac{180°}{\pi}\cdot\tan^{-1}\left(\dfrac{y_2-y_1}{x_2-x_1}\right),  & \text{if }x_1\ne x_2 \\[2ex]
0°, & \text{if }x_1=x_2
\end{cases}
$$
Here's the explanation:


*

*The internal fraction $\dfrac{y_2-y_1}{x_2-x_1}$ is the slope of the line

*The arctangent of that slope is the direction angle of the line, in standard trigonometric form (measured in radians, $0$ is to the right, positive angles are counterclockwise).

*Multiplying that radians angle by $\dfrac{180°}{\pi}$ converts it to degrees.

*Subtracting that degree angle from $90°$ changes the orientation to match that of bearings in navigation.

*That calculation fails for a vertical line, since the $x$-coordinates are equal and the slope is undefined. My formula makes that a special case: vertical lines have bearing $0°$.


There is one problem with that formula: if your two given points are identical, there is no well-defined line through them so no well-defined angle, but my formula gives an answer of $0°$. A slight modification can easily take care of that special case.

You ask about the angle of the line determined by the points $(-0.019,0.406)$ and $(-0.287,-0.353)$. Here is the calculation from my formula:

And here is what the angle looks like on a graph:

You see that the two agree. I hope the graph shows you more clearly exactly which angle my formula gives.
As for your different answers: I can't speak about your "nav bearings scale" since I don't know what that is. Check my graph to make sure we are talking about the same angle.
My formula gives values $0°<\theta<90°$ for lines with positive slope and values $90°<\theta<180°$ for lines with negative slope. However, the answer does depend on which point is point 1 and which is point 2. If you do want a formula that distinguishes between them, and also gives angles up to $360°$, here is an alternate formula that uses the atan2 function.
$$\theta = 90°-\dfrac{180°}{\pi}\cdot\operatorname{atan2}\left(x_2-x_1,y_2-y_1\right)$$
This gives an undefined value if the two points are identical. Is this what you want? (Be careful, some systems that have the atan2 function swap the $x$ and $y$ parameters.)
A: Multiply your formula result with $180/\pi$ to obtain counterclockwise angle with respect to East-West Line, following the sign convention for direction of vector placement in all four quadrants.
A: First time posting, so apologies in advance for newbie-ness.

Another example may be the following (assuming unit circle):

When the angle is from 0 to pi/2 (or 90 degrees), use: 90 - (angle * 180/pi)
When the angle is from pi/2 (90 degrees) to 2pi (or 360 degrees), use: 450 - (angle * 180/pi)

Examples:
Angle of 0:                    90 - (0pi * 180/pi)   = bearing of 90
Angle of pi/4 (45 degrees):    90 - (pi/4 * 180/pi)  = bearing of 45 
Angle of pi/2 (90 degrees):    90 - (pi/2 * 180/pi)  = bearing of 0
Angle of 3pi/4 (135 degrees): 450 - (3pi/4 * 180/pi) = bearing of 315
Angle of pi (180 degrees):    450 - (pi * 180/pi)    = bearing of 270
Angle of 7pi/4 (315 degrees): 450 - (7pi/4 * 180/pi) = bearing of 135

