Measuring the straight-line distance between two points is a basic task in geometry, mapping, navigation and game design. Our distance calculator works in three modes: points on a flat 2D graph, points in 3D space, and places on Earth given by latitude and longitude. This guide explains the formula behind each mode and how to read the results.
How to use the calculator
- Mode: 2D, 3D or latitude/longitude.
- Point 1 and point 2: enter the coordinates. In lat/long mode, the x boxes take latitude and the y boxes longitude.
The default measures from London (51.5074, −0.1278) to New York (40.7128, −74.006):
- Distance: 5,570.23 km
- Miles: 3,461.18
- Nautical miles: 3,007.68
- Initial bearing: 288.3°
2D distance
On a flat grid, the distance is the hypotenuse of a right triangle whose legs are the horizontal and vertical gaps.
From (1, 2) to (4, 6): √(3² + 4²) = √25 = 5. This is the Pythagorean theorem; the Pythagorean theorem calculator covers it in depth, and the slope calculator adds the slope and midpoint.
3D distance
Add the third coordinate:
From (1, 2, 3) to (4, 6, 15): √(9 + 16 + 144) = √169 = 13. This is used in 3D modelling, physics, robotics and finding the diagonal of a box or room.
Distance on the Earth: the haversine formula
The Earth is round, so flat-grid formulas give the wrong answer over long distances. The calculator uses the haversine formula to find the great-circle distance: the shortest path over the surface of a sphere.
Here φ is latitude, λ is longitude (both in radians) and R is the Earth's mean radius, about 6,371 km.
For London to New York, the result is about 5,570 km. Real flights are a little longer, because of wind, air traffic routes and the take-off and landing patterns.
Latitude and longitude basics
- Latitude runs from −90° (South Pole) to +90° (North Pole). North is positive.
- Longitude runs from −180° to +180°. East of Greenwich is positive, west is negative.
- Enter coordinates in decimal degrees. To convert 40° 42′ 46″ N: 40 + 42 ÷ 60 + 46 ÷ 3,600 = 40.7128.
The initial bearing
The bearing is the compass direction to set off in, measured clockwise from north: 0° is north, 90° east, 180° south and 270° west. From London to New York it is 288.3°, roughly west-north-west.
On a great-circle route the bearing changes as you travel. Flights from Europe to North America head north-west first, curving over the North Atlantic near Greenland, then turn south-west. On a flat map this looks like a detour, but on a globe it is the shortest route.
Units
| Unit | Equivalent |
|---|---|
| 1 kilometre | 0.6214 miles |
| 1 mile | 1.609 km |
| 1 nautical mile | 1.852 km (used in aviation and shipping) |
The length converter handles any other units.
Practical uses
- Travel planning: straight-line distances between cities, airports or landmarks. Combine with the fuel cost calculator for a rough trip cost, remembering roads add 20 to 40% to straight-line distance.
- Running and cycling: check the length of a route between points. The pace calculator turns distance and time into pace.
- Geometry homework: distances between points on a graph.
- Games and graphics: collision detection and range checks use 2D and 3D distance constantly.
Accuracy
The haversine formula treats the Earth as a perfect sphere, which is accurate to within about 0.5%. Surveyors use more complex ellipsoid models when every metre counts.
Frequently asked questions
Why is the flight distance longer than the calculator says?
Planes rarely fly the exact great-circle route because of winds, air corridors and airport procedures. The calculator gives the theoretical shortest distance.
How do I enter west longitude or south latitude?
Use negative numbers: −74.006 for 74.006° W, or −33.87 for 33.87° S.
What is a great circle?
The largest circle you can draw on a sphere, centred on the sphere's centre. The shortest path between two points on a sphere lies along one.
Can I use the 2D mode for map coordinates?
Only over short distances. For anything beyond a few kilometres, use the latitude and longitude mode to account for the Earth's curve.
Try it yourself
Run your own numbers with our free tool: Distance calculator. No sign-up, and it works on any device.