How do I measure distance on a globe?

I have a $3$-D sphere of radius $R$, centered at the origin.

$(x_1,y_1,z_1)$ and
$(x_2,y_2,z_2)$ are two points on the sphere.

The Euclidean distance is easy to calculate, but what if I were to restrict myself to traveling on the surface of the sphere?

Two approaches come to mind: use arc-length in some way, or simply use trigonometry: calculate the angle between the two points and get a distance from that.

Will both/either of these methods work? Which would be easier?

Somewhat related to this question. Maybe it will inspire someone to go answer it!

-
Just got out of my great-circle distance class, etc. – Larry Wang Jul 27 '10 at 1:09
Here is an online calculator for great circle distance and here is a detailed explanation of the calculations behind it. – John D. Cook Jul 27 '10 at 22:04
This is my answer on a somewhat related question--there, the question was finding angles (which is not entirely unrelated), but the bigger difference is that the points are described by latitude and longitude. The Spherical Law of Cosines and the diagrams there may be helpful. – Isaac Aug 2 '10 at 4:33

What you are looking for is what is called the great circle distance: the shortest curve connecting two points on the surface of a sphere is given by traveling along the (there will be exactly one unless the points are polar opposites) arc of the great circle (that is, the circle of radius $R$) connecting them.

So, you do need to find an arc length but it is easy to do this without invoking calculus if you know about the dot product. Suppose the two points on the circle are represented by the vectors $v$ and $w$. If $v\cdot w$ denotes the dot product of these two vectors, then the angle between them will be:

$\cos^{-1}\left(\large\frac{v\cdot w}{R^2}\right)$ (we divide by $R^2$ since $v$ and $w$ have length $R$).

Assuming this is in radians, to get the length of the arc connecting them we just multiply this angle by $R$ to get:

$R\cos^{-1}\left(\large\frac{v\cdot w}{R^2}\right)$.

We are quite lucky that there is such a simple formula. For most manifolds, the curves that minimize distances are not very easy to find since it involves solving a non-linear differential equation (the geodesic equation). The fact that the sphere is so symmetric helps in this case, and you can maybe convince yourself that an arc of a great circle minimizes distance.

You may find this wikipedia article interesting: http://en.wikipedia.org/wiki/Geodesic.

-

The linear distance ($d$) between the given points: $\color{blue}{(x_{1}, y_{1}, z_{1})}$ & $\color{blue}{(x_{2}, y_{2}, z_{2})}$ on the sphere with a radius $\color{blue}{R}$, is given as $$\color{blue}{d=\sqrt{(x_{1}-x_{2})^2+(y_{1}-y_{2})^2+(z_{1}-z_{2})^2}}$$ Now, the angle $\theta$ subtended by this chord of length $d$ at the center of the sphere is given as $$\sin\frac{\theta}{2}=\frac{\frac{d}{2}}{R}$$$$\implies \color{blue}{\theta=2\sin^{-1}\left(\frac{d}{2R}\right)}$$ Hence the distance (as a great circle arc) between the given points on the sphere with a radius $R$ is $$=\color{blue}{\text{R}\times \theta}$$ $$=\color{green}{2R\sin^{-1}\left(\frac{d}{2R}\right)}$$

-

If you have the Euclidean distance d between the two points, and set D = the diameter of the sphere (so D = 2R), then the great circle distance is D*InvSin(d/D), where InvSin is the inverse sine function. If you know that d/D is usually very small, then you can approximate the great circle distance using a few terms of the Taylor series for inverse sine.

-