Distance on a sphere: the haversine formula
On a flat map the shortest way between two cities looks like a straight line, but the Earth is round: the shortest way over its surface is an arc of a great circle, a circle whose centre is the centre of the Earth. Pick two places, such as New York and London, and watch the distance being worked out with the haversine formula d = 2R · arcsin √(sin²(Δφ/2) + cos φ₁ · cos φ₂ · sin²(Δλ/2)): the latitudes and longitudes, the triangle the places make with the pole, the angle between the two radii at the centre of the Earth, and a plane flying along the great circle. Pick a route, or choose the two places, or drag a marker over the globe to put it anywhere. Press Play to see the distance worked out in four steps: the two places with their latitude φ and longitude λ, the triangle they make with the pole (its sides from the pole are 90° − φ₁ and 90° − φ₂ and the angle between them is the difference in longitude Δλ), the central angle Δσ between the radii from the centre of the sphere to both places, and a plane flying along the great circle while the distance d = R · Δσ counts up. The panel fills the numbers into the haversine formula and lights the line of the step that plays. Drag the globe to turn it, double-click to turn it back. Step and Back jump between the steps.
Як це працює
- Pick a route such as New York → London or São Paulo → Cape Town, choose two places, or set their latitude and longitude.
- Press Play to see the four steps: the places, the triangle with the pole, the central angle between the radii and the flight along the great circle.
- Follow the formula panel: it fills in the numbers of the haversine formula and lights the line of the step that plays.
- Drag a marker over the globe to move a place, drag the globe to turn it, switch on the rhumb line to compare, and save the picture or open it in the editor with every part on its own layer.
Why the shortest way is curved
Every plane through the centre of a sphere cuts its surface in a great circle, the biggest circle that fits on it: the equator and every meridian are great circles. Through two places that are not exactly opposite each other there is just one, and the shorter of its two arcs between them is the shortest way over the surface. On a flat map the great circle looks bent towards the pole, which is why a flight from New York to London heads north-east over Newfoundland and comes down over Ireland, and a flight from Los Angeles to Sydney seems to swing far out over the Pacific.
Latitude, longitude and the triangle with the pole
A place is given by its latitude φ, the angle north or south of the equator, and its longitude λ, the angle east or west of Greenwich. Join both places to the North Pole along their meridians and you get a spherical triangle. Its sides from the pole are the colatitudes 90° − φ₁ and 90° − φ₂, and the angle between them at the pole is the difference in longitude Δλ. The third side is the great-circle arc you want, and the spherical law of cosines gives it: cos Δσ = sin φ₁ sin φ₂ + cos φ₁ cos φ₂ cos Δλ.
The haversine formula
The law of cosines loses precision for places close together, because cos Δσ is then very close to 1. The haversine form avoids that: with hav θ = sin²(θ/2), a = hav Δφ + cos φ₁ · cos φ₂ · hav Δλ and the central angle is Δσ = 2 · arcsin √a. Multiplied by the radius it gives the distance, d = R · Δσ. For New York to London, a = 0.179, Δσ = 50.1° = 0.874 rad, and with R = 6,371 km the distance is about 5,570 km. The number a has a meaning of its own: √a is half the straight chord through the Earth, in units of the radius.
Great circle or rhumb line
Sailors long preferred the rhumb line, or loxodrome, the course that crosses every meridian at the same angle, so it can be steered with one compass heading. On a Mercator map it is a straight line, but on the globe it spirals towards the pole and is longer than the great circle: about 5,790 km instead of 5,570 km from New York to London, and the difference grows with the distance and the latitude. A great-circle route has to change its heading all the way: a plane leaving New York for London sets off at about 51° and arrives heading about 108°.
Поширені запитання
What is the haversine formula?
A formula for the great-circle distance between two points on a sphere from their latitudes φ and longitudes λ: d = 2R · arcsin √(sin²((φ₂ − φ₁)/2) + cos φ₁ · cos φ₂ · sin²((λ₂ − λ₁)/2)). The haversine of an angle is sin²(θ/2), half of 1 − cos θ. Written this way the formula stays precise even for places a few metres apart, where the older law of cosines rounds badly.
How far is it from New York to London?
About 5,570 km (3,461 miles or 3,008 nautical miles) along the great circle, with the Earth taken as a sphere of radius 6,371 km. The central angle between the two cities, seen from the centre of the Earth, is 50.1°. A route with a constant compass heading, the rhumb line, would be about 5,790 km.
How far is it from São Paulo to Cape Town?
About 6,345 km along the great circle across the South Atlantic, a central angle of 57.1°. Because both cities lie in the southern hemisphere the great circle bends towards the South Pole, and the app draws the triangle with the South Pole instead of the North Pole.
Why do flight paths look curved on a map?
Because a flat map cannot show distances on a sphere correctly. The shortest way is the great circle, which on most maps bends towards the nearer pole. Seen on a globe, as in the app, it is the straightest possible line. Real flights also bend for winds such as the jet stream, air routes and restricted air space.
How accurate is the distance?
The formula itself is exact for a sphere. The Earth is slightly flattened, 21 km less from pole to pole than across the equator, so treating it as a sphere of mean radius 6,371 km gives distances that can be up to about 0.5 % off. For surveying and navigation, Vincenty's or Karney's formulas on the ellipsoid are used instead.
Can I use the picture?
Yes. Save gives a PNG at the size you choose, and the pencil opens the picture in the PictorX photo editor with the background, the globe, the grid, the great circle, the triangle with the pole, the radii and the central angle, the chord, the places, the plane and the formula panel on layers of their own, and the route, the formula, the steps, the distance and the caption as text you can edit.
Distance on a Sphere: як записати відео?
Натисніть червону кнопку «Запис» на панелі відтворення: вона знімає те, що показує сцена. Натисніть її ще раз, щоб зупинити, і відео збережеться на вашому пристрої. Запис безкоштовний, потрібно лише увійти. Без підписки на відео в куті буде невеликий логотип PictorX. Кнопка поруч із «Запис» відкриває параметри відео: формат (як показано, квадрат, сторіз 9:16 або широкий 16:9), тривалість (доки ви не зупините, або 5, 10, 15 чи 30 секунд для соцмереж) і файл: MP4, WebM або анімований GIF. Можна додати одну з трьох музичних доріжок: спокійну, яскраву чи ритмічну.
Готові спробувати?
Відкрийте PictorX у браузері — без встановлення і без кредитної картки.
Перейти до редактора