# Found a formula supposedly from the spherical law of cosines but I don't know how it comes from there

I need to convert Cartesian coordinates to lat/long coordinates or to be more specific: I have a point $P(\phi_1|\lambda_1)$ (lat/long), a heading $\theta$ (like compass heading, north is $0^{\circ}$) and a distance $d$ (from which you can calculate $\delta=d/r$). I found some formulae for this and their derivation here. However, I can't find (out) how the equation

$$\tag{1} \cos(\delta) = \sin(\varphi_1)\sin(\varphi_2) + \cos(\varphi_1)\cos(\varphi_2)\cos(\Delta\lambda)$$

is built from the spherical law of cosines as the spherical law of cosines only gives

$$\cos(a) = \cos(b)\cos(c) + \sin(b)\sin(c)\cos(A)$$

and their cyclic permutations for $\cos(b)$ and $\cos(c)$.

## 1 Answer

The spherical triangle you are interested in has a vertex at the north pole. The angular distance to the other two vertices is $90$ degrees minus their latitude, hence $\sin$ gets swapped with $\cos$.

• Wow, thanks a lot. I actually already had the same problem when trying to understand how eq. 2 was built (see link) but didn't think that would be the solution for this one as it was the first equation written in the derivation. I stand corrected. – Emil S. Dec 17 '17 at 16:32
• You are welcome. Sometimes the obvious escapes one. – Somos Dec 17 '17 at 16:34