Distance Calculator

Distance between two points in a 2D plane, in 3D space, or on Earth's surface — with a click-to-place world map, decimal or degree-minute-second input, and step-by-step working.

What is the distance formula?

The distance formula gives the straight-line (Euclidean) distance between two points. In two dimensions it comes straight from the Pythagorean theorem: the horizontal gap and the vertical gap between the two points form the two legs of a right triangle, and the distance you want is the hypotenuse. The same idea stretches into three dimensions by adding a z-term, and to two places on the Earth's surface — where a curved-space formula (Haversine or Lambert) takes over from flat-space Pythagoras.

Distance is one of the most useful measurements in geometry because so many other questions reduce to it: how long is this segment, how far apart are these two cities, how close is a point to a line, where is the middle of a road, what bearing should a plane fly? Every tab in this calculator is a different flavour of the same question — “how far?” — answered with the right formula for the geometry involved.

Distance formulas explained, method by method

For every method below you'll see a plain-English explanation, the formula (with what each letter means), a diagram, and a worked example — all in one place.

2D distance (Pythagorean)

In a flat plane, subtract the x-coordinates and the y-coordinates. Those two differences are the legs of a right triangle whose hypotenuse is the distance you want. Because each difference is squared, the order of the two points doesn't change the answer.

d = √((x₂ − x₁)² + (y₂ − y₁)²)
ddistance between the points·x₁, y₁coordinates of the first point·x₂, y₂coordinates of the second point
2D coordinate plane
P₁(1, 5)P₂(3, 2)Δy = 3Δx = 2d
Example
Given
P₁(1, 5)
P₂(3, 2)
Substitute
d = √((3 − 1)² + (2 − 5)²)
= √(4 + 9)
= √13
Answer
d ≈ 3.6056

3D distance

Space adds a third axis, z, so we add a third squared difference. The formula is Pythagoras applied twice — once in the xy-plane, then again with that flat distance and Δz.

d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
d3D straight-line distance·x, y, zcoordinates on each axis
3D coordinate space (isometric)
xzyP₁(1, 3, 7)P₂(2, 4, 8)d
Example
Given
P₁(1, 3, 7)
P₂(2, 4, 8)
Substitute
d = √(1² + 1² + 1²)
= √3
Answer
d ≈ 1.7321

Haversine (great-circle on a sphere)

For two points on Earth, the shortest path curves along the surface — a great-circle arc. Haversine assumes a perfect sphere of radius R and gives that arc length directly from the latitudes and longitudes. Convert every angle to radians first.

a = sin²(Δφ / 2) + cos φ₁ · cos φ₂ · sin²(Δλ / 2)
c = 2 · atan2(√a
√(1 − a))
d = R · c
φ₁, φ₂latitudes in radians·Δφ, Δλdifferences in latitude / longitude (radians)·REarth's mean radius (≈ 6371 km)·dgreat-circle distance
Great-circle arc on a sphere
LondonParisd
Example
Given
London (51.5074° N, 0.1278° W) → Paris (48.8566° N, 2.3522° E)
Substitute
a = 0.000727
c ≈ 0.05394 rad
d = 6371 · 0.05394
Answer
d ≈ 343.6 km (≈ 213.5 mi)

Lambert's formula (oblate spheroid)

Earth is slightly wider at the equator than pole-to-pole (equatorial 6378 km, polar 6357 km). Haversine can be off by up to about 0.5%. Lambert's formula uses the WGS-84 ellipsoid via reduced latitudes β, then adds a small flattening correction — accurate to about 10 m over thousands of kilometres.

tan β = (1 − f) · tan φ
d ≈ a · (σ − f · correction(β₁
β₂, σ))
a, fequatorial radius and flattening of WGS-84·β₁, β₂reduced latitudes: tan β = (1 − f) tan φ·dellipsoidal surface distance
Oblate spheroid (WGS-84)
polar 6357 kmequatorial 6378 km
Example
Given
Same London → Paris coordinates
Substitute
Apply flattening correction to Haversine central angle σ
Answer
d ≈ 343.55 km — within ~50 m of Haversine at this range

Degrees–Minutes–Seconds to decimal degrees

GPS and old maps often quote latitude/longitude in degrees, minutes and seconds. Convert to decimal degrees before applying any distance formula: divide minutes by 60 and seconds by 3600, then add. South and West become negative.

decimal = ± (D + M / 60 + S / 3600)
Dwhole degrees·Marc-minutes·Sarc-seconds
DMS → decimal degrees
51° 30′ 26.6″ N51.507389°
Example
Given
51° 30′ 26.6″ N
Substitute
51 + 30/60 + 26.6/3600 = 51 + 0.5 + 0.007389
Answer
≈ 51.507389°

Features of this calculator

  • 2D distance with a live coordinate-plane diagram showing the two points, the right-triangle legs (Δx, Δy) and the connecting distance segment.
  • 3D distance with an isometric sketch of the x-, y- and z-axes and both points plotted.
  • Latitude/longitude great-circle distance using the Haversine formula, plus Lambert's ellipsoidal formula for higher accuracy — results in both kilometres and miles, along with the initial and final compass bearings.
  • Decimal-degrees or degrees-minutes-seconds input, with per-coordinate N/S and E/W selectors.
  • Interactive click-to-place world map — set two points, drag either marker, see the great-circle arc and distance update live.
  • Show/hide step-by-step working for every calculation, with the formula, substitution, and final value.
  • Copy-to-clipboard buttons on every result.
  • Manhattan / Chebyshev tab comparing taxicab, chessboard-king and straight-line distance side by side for the same two points.

Frequently asked questions

+What is the distance formula?
In a 2D plane the distance between (x₁, y₁) and (x₂, y₂) is d = √((x₂ − x₁)² + (y₂ − y₁)²). It comes straight from the Pythagorean theorem — the horizontal and vertical gaps are the two legs of a right triangle and the distance is the hypotenuse.
+Does the order of the two points matter?
No. Because each difference is squared, (x₂ − x₁)² equals (x₁ − x₂)², so you get the same answer whichever point you label 1 and which one you label 2. The same is true in 3D and for the Haversine formula.
+How do I calculate distance between two GPS coordinates?
Use the Haversine formula, which gives the shortest distance across the surface of a sphere. Convert both latitudes and longitudes to radians, plug into a = sin²(Δφ/2) + cos φ₁·cos φ₂·sin²(Δλ/2), then d = 2R·asin(√a) with R ≈ 6371 km (3959 mi) for the Earth.
+Why do Haversine and Lambert's formula give slightly different answers?
Haversine assumes the Earth is a perfect sphere; the real Earth is an oblate spheroid — slightly wider at the equator than pole-to-pole. That difference can put Haversine off by up to about 0.5%. Lambert's formula corrects for the flattening and is usually accurate to within about 10 metres over thousands of kilometres.
+What's the difference between great-circle distance and driving distance?
Great-circle distance is the shortest possible path between two points along the Earth's surface, as the crow flies. Driving distance follows actual roads, which are longer and depend on the route. This calculator gives great-circle distance only.
+Can I enter coordinates in degrees, minutes, seconds?
Yes — switch the lat/long tab to DMS. Enter each coordinate as three numbers (degrees, minutes, seconds) plus a hemisphere. The calculator converts to decimal degrees using ± (degrees + minutes/60 + seconds/3600), with South and West being negative.
+What is final bearing versus initial bearing?
Initial bearing is the compass direction you head in when leaving point A along the great-circle path to B. Because the Earth is curved, that direction drifts as you travel, so the direction you're facing when you arrive at B — the final bearing — is usually different. It's calculated by finding the initial bearing from B back to A, then adding 180° (mod 360°).
+What are Manhattan and Chebyshev distance used for?
Manhattan (taxicab) distance sums |Δx| + |Δy| and matches movement restricted to horizontal/vertical steps, such as city blocks or grid-based pathfinding (e.g. A* on a 4-directional grid). Chebyshev distance takes max(|Δx|, |Δy|) and matches movement where diagonal steps cost the same as straight ones, such as a king's moves on a chessboard.

Related calculators