Distance in a 2D coordinate plane
The distance between two points (x₁, y₁) and (x₂, y₂) on a flat plane comes straight from the Pythagorean theorem. The horizontal and vertical differences form the legs of a right triangle, and the distance is its hypotenuse:
Example: from (1, 1) to (4, 5), ΔX = 3 and ΔY = 4, so d = √(9 + 16) = √25 = 5. The same differences also give the slope, ΔY / ΔX = 4/3 ≈ 1.3333333333333, and the direction of travel, arctan(4/3) ≈ 53.130102354156° counterclockwise from the positive x-axis.
Distance in 3D space
Adding a third axis simply adds one more squared difference under the root:
Example: from (3.5, −2, 4) to (−7, 9.25, −1.5), the differences are −10.5, 11.25 and −5.5. Their squares sum to 110.25 + 126.5625 + 30.25 = 267.0625, so the distance is √267.0625 ≈ 16.342046995404. The sign of each difference does not matter because it is squared.
Distance between two points on Earth
On a globe, the shortest path between two places is not a straight line on a map but a curve along the surface. Two common ways to compute it are the haversine formula and Lambert's formula.
Haversine formula
The haversine formula treats Earth as a perfect sphere of radius R and finds the great-circle distance:
Here φ is latitude and λ is longitude, both in radians. With the mean radius of about 6,371 km, the result is usually within about 0.5% of the true distance. The error comes from Earth not being a sphere: its radius is about 6,378 km at the equator and about 6,357 km at the poles.
Lambert's formula
Lambert's formula corrects for that flattening. It first converts each latitude to a reduced latitude on the WGS-84 ellipsoid (equatorial radius 6,378,137 m, flattening 1/298.257223563), computes the central angle σ between the points, then applies a correction:
where X and Y depend on σ and on the mean and half-difference of the latitudes. For long distances it agrees with far more complex geodesic methods to within about 10 meters, which is why this calculator uses it for the headline figure.
Worked example
From the White House (38.8976, −77.0366) to Philadelphia's Independence Hall area (39.9496, −75.1503), Lambert's formula gives about 200.0 km, or 124.3 miles. New York (40.7128, −74.006) to Los Angeles (34.0522, −118.2437) is about 3,944.4 km (2,450.9 miles), and London to Sydney is about 16,989.2 km.
Entering coordinates
Use decimal degrees with north and east positive and south and west negative, or switch to degrees, minutes and seconds and choose N/S and E/W. One minute is 1/60 of a degree and one second is 1/3600, so 38° 53' 51.36" equals 38.8976°.
Limits of the formulas
These are surface distances "as the crow flies". Driving or walking routes are longer, and flight paths vary with winds and air corridors. The 2D and 3D formulas assume flat Euclidean space, so do not use them directly on latitude and longitude values except for very short distances.
Choosing the right mode
Use the 2D mode for points on a flat drawing, map grid or graph, and the 3D mode when height or depth matters, such as in CAD models, physics problems or game coordinates. Use the latitude and longitude mode for real places on Earth; the result is the shortest route over the surface, often called the great-circle distance.