Angle between two points on a sphere Suppose I am standing at point $A$ on Earth (a 3D sphere of a known radius) and suppose $B$ is another point a few miles away. The longitude and latitude of points $A$ and $B$ are $(\lambda_1,\varphi_1)$ and $(\lambda_2,\varphi_2)$ respectively. What is the angle from $A$ to $B$? In other words, If I was holding a compass whose needle points north while standing at point $A$, at what angle will point $B$ be?
 A: There are two laws of cosines for spherical triangles:
$$\begin{align}\cos a&=\cos b\cos c+\sin b\sin c\cos A\\
\cos A&=-\cos B\cos C+\sin B\sin C\cos a\end{align}$$
Where $A$, $B$, and $C$ are the angles of the spherical triangle and $a$, $b$, and $c$ are the opposite side. Here you know one angle and two sides of the spherical triangle with vertices at the cities and the north pole:
$$\begin{align}b=\frac{\pi}2-\phi_1,&&c=\frac{\pi}2-\phi_2,&&\text{and}\quad A=\lambda_2-\lambda_1\end{align}$$
So you can apply the first of the two laws to get
$$\cos a=\sin\phi_1\sin\phi_2+\cos\phi_1\cos\phi_2\cos(\lambda_2-\lambda_1)$$
Then the distance between the two cities is $Ra$, where $R$ is the radius of the earth and $a$ is the angle we just computed in radians. Oh, but you wanted the bearing. There is also a law of sines:
$$\frac{\sin A}{\sin a}=\frac{\sin B}{\sin b}=\frac{\sin C}{\sin c}$$
So we can now get
$$\sin C=\frac{\sin A\sin c}{\sin a}$$
And $C$ is the bearing from city $1$ to city $2$ measured east of north.
