Derivation of formula for heading to another point (lat/long)

754 Views Asked by At

I know the formula for calculating the heading between to given points (latitude, longitude) is $$ \tag{1} \theta = \arctan2(\sin(\Delta\lambda)*\cos(\varphi_2), \cos(\varphi_1)*\sin(\varphi_2) − \sin(\varphi_1)*\cos(\varphi_2)*\cos(\Delta\lambda)) $$ where $\theta$ is the heading from the starting point $P_1(\varphi_1, \lambda_1)$ (latitude, longitude) to the target point $P_2(\varphi_2, \lambda_2)$ and the difference in longitude is $\Delta\lambda = \lambda_2 - \lambda_1$ unless the great circle between the points crosses longitude $\pi$ or $-\pi$, in which case you have to correct. Equation 1 comes from the formula $$\tag{2} \tan(\theta) = \frac{\sin(\Delta\lambda)\cos(\varphi_2)}{\cos(\varphi_1)\sin(\varphi_2)-\sin(\varphi_1)\cos(\varphi_2)\cos(\Delta\lambda)} $$ but I don't know where this one comes from. Can anyone provide a derivation as I want to understand how this formula came to be.