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.)
Best Answer
If $\theta$ is your original angle, then $(-\theta + 90^{\circ}) \bmod 360^{\circ}$ will work. The negative on $\theta$ deals with the fact that we are changing from counterclockwise to clockwise. The $+90^{\circ}$ deals with the offset of ninety degrees. And lastly we need to mod by $360^{\circ}$ to keep our angle in the desired range $[0^{\circ},360^{\circ}]$.