Distance Calculator
Find the straight-line distance between two points in 2D or 3D, or the great-circle distance between two latitude/longitude coordinates on Earth.
How to use this calculator
- 1Choose 2D, 3D, or latitude/longitude for two places on Earth.
- 2Enter both points. Negative coordinates are fine (south and west are negative for latitude/longitude).
- 3The step table shows each stage of the calculation for 2D and 3D; latitude/longitude shows distance, bearing, and both metric and imperial units.
How the calculation works
d = √((x₂−x₁)² + (y₂−y₁)²)
3D: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²)
Earth: haversine formula on latitude/longitude- (x₁, y₁)
- The first point
- (x₂, y₂)
- The second point
- d
- Straight-line (Euclidean) distance, or great-circle distance for latitude/longitude
This is the Pythagorean theorem applied to coordinates: the horizontal and vertical gaps are the legs of a right triangle and the distance is its hypotenuse.
Order does not matter — the differences are squared, so swapping the points gives the same distance.
The midpoint is simply the average of each coordinate.
Latitude/longitude mode uses the haversine formula instead, which accounts for the Earth's curvature — the flat-plane formula above would be badly wrong at that scale.
Worked example
From (1, 2) to (7, 10)
- 1.Δx = 7 − 1 = 6, Δy = 10 − 2 = 8.
- 2.Square and sum: 36 + 64 = 100.
- 3.Square root: √100 = 10.
- 4.Notice this is a 6-8-10 triangle — a scaled 3-4-5 Pythagorean triple.
Result: Distance 10, midpoint (4, 6)
New York to London
- 1.Convert both coordinates to radians and apply the haversine formula.
- 2.The great-circle distance comes out to about 5,570 km.
- 3.That is roughly 3,461 miles — noticeably shorter than a straight line drawn on a flat map would suggest, since the shortest path over a sphere curves toward the pole.
Result: ≈ 5,570 km (3,461 miles)
What "distance" means here
Distance, in the everyday sense this calculator uses, is the length of the straight line connecting two points — the shortest path between them, ignoring any obstacles or the route you would actually have to travel. Mathematicians call this Euclidean distance, and it applies equally whether the two points sit on a flat 2D plane, in 3D space, or — with a modification — on the curved surface of a sphere like the Earth.
A coordinate system is what makes "distance" computable at all: by describing every point as a set of numbers (an x and y position, or a latitude and longitude), the gap between two points becomes something that can be measured with arithmetic rather than a ruler.
Where the distance formula comes from
The 2D distance formula is the Pythagorean theorem wearing a different name. Plot two points and draw a horizontal line and a vertical line connecting them, and those two lines are the legs of a right triangle — the horizontal gap is one leg, the vertical gap is the other, and the straight-line distance between the points is the hypotenuse. Extending to three dimensions just adds a third leg for the depth difference, applying the same theorem twice.
Because both coordinate differences get squared before being added, it never matters which point is "first" — swapping the two points gives exactly the same distance, the same way walking a path backwards covers the same ground.
Measuring distance on a curved surface
The flat-plane distance formula quietly assumes the two points sit on a flat surface, which stops being a safe assumption once the distance involved is large enough for the Earth’s curvature to matter. A straight line drilled through the Earth from New York to London would be shorter than any path along the surface — but no vehicle can take that route.
For latitude and longitude, this calculator instead uses the haversine formula, which computes the great-circle distance: the shortest path between two points that stays on the surface of a sphere. It is the same reason long-haul flights curve up toward the poles on a flat map instead of drawing what looks like the "straight" line across it — the curved-looking path is actually the shorter one on a sphere.
Where distance calculations show up
Measuring the gap between two points, in whichever coordinate system fits the problem, is one of the most widely reused pieces of geometry there is.
- GPS and navigation — every turn-by-turn direction and "distance to destination" figure starts from a distance calculation between coordinates, often refined for the curvature of the Earth.
- Surveying — establishing exact distances between fixed points underlies property boundaries, construction layouts and mapping.
- Physics — the magnitude of displacement, velocity and force vectors is found with exactly this formula, treating each component like a coordinate axis.
- Computer graphics and game development — collision detection, pathfinding and rendering all rely constantly on measuring the distance between points in 2D or 3D space.
- Logistics and shipping — great-circle distance gives the shortest possible sea or air route between two ports or airports, before real-world routing constraints are added.
Straight-line distance versus travel distance
Euclidean distance is not the only useful notion of "how far apart" two points are. Manhattan distance — named for the grid of city blocks on Manhattan island — measures distance along the axes instead of straight through, the way a taxi actually has to drive on a rectangular street grid rather than cutting diagonally across buildings. It is always equal to or greater than the straight-line distance, and the two only match when the points share a row or column.
What this assumes, and where it stops
Assumptions
- 2D and 3D modes assume a flat Cartesian coordinate system. Latitude/longitude mode assumes a perfectly spherical Earth.
Limitations
- The 2D/3D flat-plane formula is not valid for distances on the Earth's surface — use latitude/longitude mode for that, which applies the haversine formula instead.
- Manhattan distance (2D/3D modes) assumes a perfect grid; real street layouts rarely are one.
- The haversine formula treats Earth as a perfect sphere. A full ellipsoidal calculation (Vincenty's formula) is more precise but the difference is under about 0.5% for almost any practical purpose.
Common questions
What is the distance formula?
d = √((x₂−x₁)² + (y₂−y₁)²). It is the Pythagorean theorem with the two coordinate differences as the legs of a right triangle — the horizontal gap, the vertical gap, and the straight-line distance as the hypotenuse.
Can I use this for distances between cities?
Yes — switch "Dimensions" to latitude/longitude and enter each place's coordinates. That mode uses the haversine formula instead of the flat-plane one, since latitude and longitude sit on a sphere and the ordinary distance formula would give a meaningfully wrong answer over long ranges.
Sources
- Haversine formula — Wikipedia
Formula and content last reviewed on .
Results are estimates for information only, not professional advice.
Related calculators
Tools people commonly use alongside the distance calculator.