Measure distance between 2D or 3D points, and great-circle distance between coordinates.
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.
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)
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.
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.
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).