Understanding the great-circle distance calculator — concept and principle
This calculator finds the shortest distance over Earth's surface between two points given by latitude and longitude, together with the initial compass bearing from the first point. The shortest path on a sphere follows a great circle, which long-haul flights approximate.
How it is calculated
With latitudes φ₁, φ₂ and longitude difference Δλ in radians:
- a = sin²(Δφ / 2) + cos φ₁ × cos φ₂ × sin²(Δλ / 2)
- Central angle c = 2 × arcsin(√a)
- Distance d = R × c, with mean Earth radius R = 6,371.0088 km
- Initial bearing θ = atan2(sin Δλ × cos φ₂, cos φ₁ × sin φ₂ − sin φ₁ × cos φ₂ × cos Δλ), converted to 0–360°
Miles = km ÷ 1.609344 and nautical miles = km ÷ 1.852.
The principle
On a sphere, distance along the surface equals the radius times the angle between the two points measured at the centre. The haversine function, hav θ = sin²(θ/2), lets you compute that angle from the spherical law of cosines in a form that stays numerically accurate even for points very close together, where the ordinary cosine formula loses precision. The bearing formula comes from the same spherical triangle formed by the two points and the North Pole. Because a great circle is not a line of constant compass heading, the bearing changes along the way; the value shown is the heading at departure.
Worked example
- Inputs: Seoul (37.5665° N, 126.9780° E) to Tokyo (35.6762° N, 139.6503° E).
- Δφ = −1.8903°, Δλ = 12.6723°.
- a = sin²(−0.945°) + cos 37.5665° × cos 35.6762° × sin²(6.336°) = 0.0081144.
- c = 2 × arcsin(0.090080) = 0.180405 rad (10.34°).
- d = 6,371.0088 × 0.180405 = 1,149.358923 km = 714.1785245 mi = 620.6041703 nmi.
- Initial bearing = 96.69609077°, just south of due east.
| Longitude 2 | Distance (km) |
|---|---|
| 34.9 | 7,849.009499 |
| 69.8 | 5,024.416886 |
| 105 | 1,991.211592 |
| 140 | 1,149.332662 |
| 175 | 4,206.158541 |
| 209 | 7,107.443055 |
| 279 | 11,385.78578 |
How to read the result
The distance is "as the crow flies"; road, rail or flight routes are always longer because of terrain, airways and airports. Bearings are measured clockwise from true north (0° north, 90° east, 180° south, 270° west), not magnetic north.
Common mistakes
- Mixing up the order of latitude and longitude, or entering west and south values as positive.
- Using degrees-minutes-seconds without converting to decimal degrees (37°34′ = 37.567°).
- Expecting millimetre accuracy; the sphere model can differ from ellipsoid (GPS) values by up to about 0.5%.
Frequently asked questions
Why does a flight from Seoul to New York pass near the Arctic?
On a flat map the great circle looks curved, but on the globe it is the shortest path, and for northern-hemisphere routes it bends toward the pole.
Why use 6,371.0088 km for the radius?
It is the mean radius (2a + b)/3 of the GRS 80 / WGS 84 ellipsoid, as recommended by the IUGG.
What is the bearing for the return trip?
It is not simply the opposite heading; compute it again with the points swapped.
Sources: R. W. Sinnott, Virtues of the Haversine, Sky and Telescope 68(2), 159 (1984) · H. Moritz, Geodetic Reference System 1980, Journal of Geodesy 74, 128–133 (2000) · C. F. F. Karney, Algorithms for geodesics, Journal of Geodesy 87, 43–55 (2013)