get the angle between a and b using their coordinates I am working on some simulation software, and I want to get the bearing of one point in the simulation from the position of another. I have a point A at position (lat, lon), I also have an entity B which is moving around point A (point A is static- not moving at all). Given that B is constantly moving, its lat/ lon values are constantly changing.
How can I get the angle at which point B lies from point A at any given time? i.e. where between 0- 360 does B lie from A? Is there a way of doing this using just the two points' lat/ lon values?
 A: By "bearing", I assume you mean "azimuth," i.e., the angle, measured clockwise, between the line from $A$ to the north pole, $N$, and the line from $A$ to $B$. 
Quick and dirty solution: convert $A$, $B$, and $N$ into rectangular coordinates, and use dot and cross products. To convert lat-long coords $(p, q)$ to rectangular ones, compute
$$
x = \cos p \cos q \\
y = \cos p \sin q \\
z = \sin p
$$
So from now on, I'm going to treat the letter $A$ as shorthand for the xyz-coords of point $A$. 
Compute 
$$
v = N - A \\
w = B - A
$$
Define the "dot product" of $(x_1, y_1, z_1)$ and $(x_2, y_2, z_2)$ as $x_1 x_2 + y_1 y_2 + z_1 z_2$. Write this as $X \cdot Y$. 
Now compute
\begin{align}
v' &= v - (v \cdot A) A   \text{, using termwise subtraction}\\
w' &= w - (w \cdot A) A   \text{ and $c(x,y,z)$ means $(cx, cy, cz)$.}
\end{align}
and then 
$$
v'' = v' / \sqrt{v' \cdot v'}\\
w'' = w' / \sqrt{w' \cdot w'}\\
q = v'' \times A 
$$
where that last item is a "cross product of vectors," which you'll have to look up, because I'll surely make a sign error if I try to write ti from memory, and the division in the first two items means "divide each entry of the triple by this one number".  
Let 
$$
c = w'' \cdot v''\\
s= w'' \cdot q
$$
Finally, 
$$
\theta = atan2(s, c)
$$
is the angle you want. 
