Hand Calculations logo Hand Calculations All help pages ▾

Great-Circle Distance⚠ unverified

Aerospace / Navigation · Great-circle distance between two lat/lon points

Parameters

InputSymbolUnitDefaultDescription
lat1lat1deg0.0Start latitude
lon1lon1deg0.0Start longitude
lat2lat2deg0.0End latitude
lon2lon2deg1.0End longitude
RRm6371000.0Earth radius
OutputSymbolUnitDescription
ddmDistance

The science & history

Understanding the Parameters

Derivation (Approaching a Proof)

The arc-length relation $d = R\,\Delta\sigma$ is definitional (arc length = radius × subtended angle, in radians). The real content is finding the central angle $\Delta\sigma$ from latitude/longitude — the haversine formula.

Place both points on a unit sphere and write their positions as 3-D unit vectors. The haversine of an angle is $\operatorname{hav}(\theta) = \sin^2(\theta/2) = (1-\cos\theta)/2$. Consider the two points with latitudes $\phi_1, \phi_2$ and longitude difference $\Delta\lambda$. The spherical law of cosines gives the central angle:

$$\cos\Delta\sigma = \sin\phi_1\sin\phi_2 + \cos\phi_1\cos\phi_2\cos\Delta\lambda.$$

Convert to haversine form using $\operatorname{hav}(\Delta\sigma) = (1-\cos\Delta\sigma)/2$. Substituting and applying the identity $\operatorname{hav}(\Delta\lambda) = (1-\cos\Delta\lambda)/2$ together with $\operatorname{hav}(\Delta\phi)$ for the latitude difference, the cross terms collapse (a standard spherical- trigonometry manipulation) to the compact law of haversines:

$$\operatorname{hav}(\Delta\sigma) = \operatorname{hav}(\Delta\phi) + \cos\phi_1\cos\phi_2\,\operatorname{hav}(\Delta\lambda).$$

Writing the haversines explicitly as $\sin^2(\cdot/2)$:

$$\sin^2\!\frac{\Delta\sigma}{2} = \sin^2\!\frac{\Delta\phi}{2} + \cos\phi_1\cos\phi_2\,\sin^2\!\frac{\Delta\lambda}{2} \equiv a.$$

Solve for $\Delta\sigma$ by inverting the half-angle sine (using $\arcsin$, which is well-conditioned near 0):

$$\Delta\sigma = 2\arcsin\!\sqrt{a},$$

and multiply by the radius:

$$d = R\,\Delta\sigma = 2R\arcsin\!\sqrt{\sin^2\!\tfrac{\Delta\phi}{2} + \cos\phi_1\cos\phi_2\sin^2\!\tfrac{\Delta\lambda}{2}}. \qquad\blacksquare$$

This is exactly the implemented formula. The genius of the haversine arrangement is purely numerical: it moves all the small-angle behaviour into $\sin^2$ and $\arcsin$, avoiding the catastrophic cancellation that $\arccos(\approx 1)$ would suffer.

Sanity check. From the equator point $(0^\circ,0^\circ)$ to $(0^\circ,1^\circ)$: $\Delta\phi=0$, $\cos\phi_1\cos\phi_2=1$, $a=\sin^2(0.5^\circ)$, so $d = 2R\cdot 0.5^\circ$ in radians $= 6{,}371{,}000\times(1^\circ\text{ in rad}) = 6{,}371{,}000\times 0.017453 \approx 111{,}195\ \text{m}$ — the familiar "$1^\circ \approx 111\ \text{km}$." ✓

Dimensional check. $\Delta\sigma$ is an angle in radians (dimensionless), so $d = R\,\Delta\sigma$ carries the metres of $R$ ✓.

History and Development

Related Concepts: Initial Heading, Cross Track Error, Time To Go, Ground Track Velocity, Gravitational Force

Notes: Shortest surface path = arc of a great circle (sphere's geodesic). $d=R\,\Delta\sigma$; the implementation gets $\Delta\sigma$ from the haversine formula (numerically robust for small angles, unlike $\arccos$ of the law of cosines). Inputs in degrees; $R$ = mean radius $6{,}371$ km. Spherical model (~0.5 % vs the WGS-84 ellipsoid / Vincenty). $1'$ of arc $\equiv 1$ nautical mile; $1^\circ\approx111$ km.

← Back to the workspace  ·  All help pages  ·  Getting started