Distance Calculator
Measure Euclidean distance in 2D or 3D, or great-circle distance between lat/lon coordinates.
Inputs
Distance
5.000000
Unit
units
Step by step
Δx
3 − 0
= 3
Δy
4 − 0
= 4
Distance
√(3² + 4²) = √25
= 5
How it works
The 2D and 3D Euclidean distance formulas apply the Pythagorean theorem directly to coordinate differences. In 2D: d = √((x₂−x₁)² + (y₂−y₁)²). In 3D, add (z₂−z₁)². For points on a sphere (lat/lon), the haversine formula gives the great-circle distance — the shortest path along the Earth's surface, which differs significantly from straight-line distance for long ranges.
Formulas
2D Euclidean
d = √((x₂−x₁)² + (y₂−y₁)²)
3D Euclidean
d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²)
Haversine
d = 2R arctan2(√a, √(1−a)); a = sin²(Δφ/2) + cosφ₁ cosφ₂ sin²(Δλ/2)
- R
- Earth's mean radius (6371 km)
- φ
- Latitude (radians)
- λ
- Longitude (radians)
Frequently Asked Questions
What is the difference between Euclidean and great-circle distance?
Euclidean distance is the straight-line 'as the crow flies' distance through space (or on a flat plane). Great-circle distance is the shortest path along the curved surface of a sphere. For geographic distances over more than a few hundred kilometres, the great-circle distance differs meaningfully from the flat-plane approximation.
Why is the haversine formula used instead of the simpler spherical law of cosines?
The cosine formula (d = R × arccos(sin φ₁ sin φ₂ + cos φ₁ cos φ₂ cos Δλ)) suffers from floating-point precision loss for very short distances. The haversine variant remains numerically stable even when the two points are only metres apart.
What is the distance between New York and London?
Using the haversine formula: New York is approximately 40.71°N, −74.01°E; London is 51.51°N, −0.13°E. The great-circle distance is approximately 5570 km (3461 miles).