Distance between two points on a sphere.

If $a = (a_{1}, a_{2}, a_{3})$ and $b = (b_{1}, b_{2}, b_{3})$ are points on a sphere of radius $r > 0$ centered at the origin of Euclidean $3$-space, the distance from $a$ to $b$ along the surface of the sphere is $$ d(a, b) = r \arccos\left(\frac{a \cdot b}{r^{2}}\right) = r \arccos\left(\frac{a_{1}b_{1} + a_{2}b_{2} + a_{3}b_{3}}{r^{2}}\right). $$ To see this, consider the plane through $a$, $b$, and the origin. If $\theta$ is the angle between the vectors $a$ and $b$, then $a \cdot b = r^{2} \cos\theta$, and the short arc joining $a$ and $b$ has length $r\theta$.


After practicing with Sine/Cosine Rules of spherical Trig and getting their flavor I find ready-made

formula

useful, especially to check special cases.

EDIT1:

The Clairauts Law of geodesics says

$ r \sin \beta = a \sin \lambda $

where r is radius, $a$ sphere radius, $\beta$ is path's angle to meridian, and $ \lambda $ is co-latitude.