Two Points on a Sphere: Why the Dot Product Measures Distance

Two Points on a Sphere: Why the Dot Product Measures Distance

How can a single dot product determine the shortest distance between two points on a sphere? The answer connects vectors, trigonometry, calculus, navigation, and geometry in any dimension.

1. Two meanings of distance

On a flat sheet, the shortest path between two points is a straight segment. On the surface of a sphere, however, a straight segment generally passes through the sphere. If travel is restricted to the surface, the shortest route is an arc of a great circle, a circle obtained by intersecting the sphere with a plane through its center.

Let 𝐱 and 𝐲 be points on the unit sphere in ℝ3, so ∥𝐱∥=∥𝐲∥=1. Their dot product satisfies

𝐱⋅𝐲=cosθ,0≤θ≤π,

where θ is the angle between the radius vectors. Since the unit great circle has radius one, its shorter arc has length θ. Thus

dS(𝐱,𝐲)=arccos(𝐱⋅𝐲).

On a sphere of radius R, with position vectors 𝐩,𝐪 of length R, the formula becomes

dS(𝐩,𝐪)=Rarccos(𝐩⋅𝐪R2).
xyOsurface arcchord

Figure 1. The surface route and the straight chord join the same endpoints. The sketch is schematic; the exact arc is a great-circle arc.

2. Chord distance versus spherical distance

The ordinary Euclidean distance between the two unit vectors is

dE=∥𝐱−𝐲∥.

Expanding the square gives

dE2=(𝐱−𝐲)⋅(𝐱−𝐲)=2−2𝐱⋅𝐲=2−2cosθ.

Using 1−cosθ=2sin2(θ/2), we obtain

dE=2sin(dS2).

For example, if the central angle is π/3, the chord length is 1, whereas the spherical distance is π/3. They agree approximately for nearby points, but not for distant ones.

Because sint≤t for t≥0, we have dE≤dS. More precisely,

2πdS≤dE≤dS,0≤dS≤π.

The lower bound follows from the concavity of sine on [0,π/2]. Both constants are sharp: the upper bound is approached as the points merge, and the lower bound is attained for antipodal points.

3. Why is a great circle really the shortest path?

So far, we have computed the length of a great-circle arc. But why can no other surface curve be shorter? Here is a proof using only vectors and a basic inequality from calculus.

Fix 𝐱∈Sn−1, and let γ:[a,b]→Sn−1 be any piecewise continuously differentiable curve from 𝐱 to 𝐲. Define its angular separation from the starting point by

α(t)=arccos(𝐱⋅γ(t)).

Where 0<α(t)<π, differentiation gives

α′(t)=−𝐱⋅γ′(t)sinα(t).

Since ∥γ(t)∥=1, differentiating γ⋅γ=1 shows that γ⋅γ′=0. Therefore

𝐱⋅γ′=(𝐱−(𝐱⋅γ)γ)⋅γ′.

The vector in parentheses has length

1−(𝐱⋅γ)2=sinα.

By Cauchy-Schwarz,

|𝐱⋅γ′|≤sinα∥γ′∥,so|α′|≤∥γ′∥.

The same inequality holds for the accumulated change in α across the exceptional values 0 and π, by continuity and the Lipschitz property of the angular-distance function along a smooth curve (or by applying the inequality on intervals away from those values and taking limits). Consequently,

L(γ)=∫ab∥γ′(t)∥dt≥|α(b)−α(a)|=arccos(𝐱⋅𝐲).

Now set θ=arccos(𝐱⋅𝐲), with 0<θ<π, and choose the unit vector

𝐮=𝐲−cosθ𝐱sinθ.

Then 𝐮⊥𝐱, and the curve

γ0(s)=coss𝐱+sins𝐮,0≤s≤θ,

lies on the unit sphere, joins the endpoints, and satisfies ∥γ0′(s)∥=1. Its length is exactly θ, proving the minimum. Identical endpoints have distance zero. For antipodal endpoints, any half of a great circle has length π and is minimizing.

Conclusion. The formula arccos(𝐱⋅𝐲) is not merely the length of a convenient path: it is the smallest possible length among all surface paths connecting the points.

4. Why the formula satisfies the triangle inequality

A distance must obey the triangle inequality. The shortest-path interpretation immediately implies

arccos(𝐱⋅𝐳)≤arccos(𝐱⋅𝐲)+arccos(𝐲⋅𝐳).

Indeed, travel from 𝐱 to 𝐲 along a shortest arc, then from 𝐲 to 𝐳. This produces a surface path of length dS(𝐱,𝐲)+dS(𝐲,𝐳). The shortest path directly from 𝐱 to 𝐳 cannot be longer.

There is also a purely algebraic proof. Write a=arccos(𝐱⋅𝐲) and b=arccos(𝐲⋅𝐳). Decompose

𝐱=cosa𝐲+𝐮,𝐳=cosb𝐲+𝐯,

where 𝐮,𝐯⊥𝐲, ∥𝐮∥=sina, and ∥𝐯∥=sinb. Cauchy-Schwarz yields

𝐱⋅𝐳=cosacosb+𝐮⋅𝐯≥cosacosb−sinasinb=cos(a+b).

If a+b≤π, the fact that arccosine is decreasing gives dS(𝐱,𝐳)≤a+b. If a+b>π, the conclusion is automatic because spherical distances never exceed π. Thus the triangle inequality is proved directly from vector algebra.

5. From vectors to latitude and longitude

Suppose a location on an ideal spherical Earth of radius R has latitude ϕ and longitude λ, both measured in radians. Its position vector is

𝐩=R(cosϕcosλ,cosϕsinλ,sinϕ).

For two locations, dividing their dot product by R2 and using the cosine difference identity gives

𝐩1⋅𝐩2R2=sinϕ1sinϕ2+cosϕ1cosϕ2cos(λ1−λ2).

Hence the great-circle distance is

d=Rarccos(sinϕ1sinϕ2+cosϕ1cosϕ2cos(λ1−λ2)).

Example. Consider two points on the equator separated by 90∘ in longitude. Their central angle is π/2, so their surface distance is πR/2, whereas the straight chord through the Earth has length 2R.

For very close geographical points, the arccosine formula can lose numerical accuracy because its argument is near one. In software, the equivalent haversine formula is often preferable:

h=sin2(ϕ2−ϕ12)+cosϕ1cosϕ2sin2(λ2−λ12), d=2Rarcsinh.

Real Earth is not a perfect sphere, so precise geodesic calculations use an ellipsoidal model.

6. The same formula in every dimension

I came across this formula again while researching Gelfand widths, a topic in approximation theory where the geometry of high-dimensional spheres plays a central role. The formula itself is classical, but it is exactly the tool needed there.

Nothing in the shortest-path proof depended on having exactly three coordinates. On the unit sphere

Sn−1={𝐱∈ℝn:∥𝐱∥=1},

we still have

dSn−1(𝐱,𝐲)=arccos(𝐱⋅𝐲).

The shortest arc always lies in the two-dimensional plane spanned by the endpoint vectors, provided they are not parallel. Thus a problem in an arbitrarily high-dimensional space reduces to an ordinary circle!

7. A bonus: how to interpolate along the sphere

Suppose we want not just the distance but the point a fraction t of the way along the shortest arc. For 0<θ<π, where θ=dS(𝐱,𝐲), the constant-speed interpolation is

γ(t)=sin((1−t)θ)sinθ𝐱+sin(tθ)sinθ𝐲,0≤t≤1.

To see why, substitute 𝐲=cosθ𝐱+sinθ𝐮. The expression simplifies to

γ(t)=cos(tθ)𝐱+sin(tθ)𝐮.

It follows that ∥γ(t)∥=1, γ(0)=𝐱, γ(1)=𝐲, and ∥γ′(t)∥=θ. This construction is known as spherical linear interpolation, or SLERP. It is useful for smoothly interpolating directions and orientations in computer graphics and robotics.

At θ=0, use the constant path. At θ=π, the endpoints are antipodal and there are infinitely many shortest semicircular paths, so an additional direction must be chosen.

8. Try it yourself

  1. For 𝐱=(1,0,0) and 𝐲=(0,1,0), compute both the chord and spherical distances.
  2. Find the spherical distance between 𝐱=(1,0,0) and 𝐲=(−1,0,0). How many shortest surface paths connect them?
  3. Prove that dS/dE→1 as 𝐲→𝐱, with 𝐲≠𝐱.
  4. Show that the midpoint of the shorter great-circle arc is (𝐱+𝐲)/∥𝐱+𝐲∥ whenever the endpoints are distinct and not antipodal.

Answers and hints

1. dE=2, dS=π/2. 2. dS=π; infinitely many shortest semicircles. 3. Use dE=2sin(dS/2) and sinu/u→1. 4. The normalized vector sum bisects the central angle.

Final thought

A dot product seems like a simple algebraic operation. Yet, after taking an arccosine, it becomes the natural distance on a curved space. The same identity explains great-circle navigation, the geometry of high-dimensional unit vectors, and smooth interpolation on spheres. Sometimes the most useful geometric formulas are hiding inside familiar algebra.

The spherical distance formula relies on the Cauchy-Schwarz inequality , which guarantees that the dot product of two unit vectors lies between -1 and 1. This fundamental inequality connects vector geometry, distances, and angles.

For an integral that uses the same symmetry of the sphere, read A Surprising Integral on the Sphere: Why Every Direction Is the Same.

Leave a Reply

Your email address will not be published. Required fields are marked *