How the Haversine Formula Calculates Distance
Calculating straight-line distance on Earth cannot be accomplished using simple 2D Pythagorean theorem ($a^2 + b^2 = c^2$) because the Earth is a curved sphere.
The Haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes:
$$\text{hav}(\theta) = \sin^2\left(\frac{\Delta\phi}{2}\right) + \cos(\phi_1)\cos(\phi_2)\sin^2\left(\frac{\Delta\lambda}{2}\right)$$
Where $\phi_1, \phi_2$ are latitudes, $\lambda_1, \lambda_2$ are longitudes in radians, and the distance is $d = 2R \cdot \arcsin(\sqrt{\text{hav}(\theta)})$, with $R \approx 6,371$ km representing the Earth's volumetric mean radius.
Great-Circle Distance vs. Rhumb Line
- Great-Circle Path: The shortest possible route between two points on the sphere. On standard flat Mercator maps, great circles appear curved (e.g. flights from New York to London arc upward over Greenland).
- Rhumb Line (Loxodrome): A path of constant compass bearing. It is longer than a great-circle route but historically easier for mariners steering by magnetic compass.