How it works
The straight-line distance between two points comes from the Pythagorean theorem: the horizontal and vertical differences are the legs of a right triangle, and the distance is the hypotenuse.
In 3D, the z difference is added under the square root. When the squared distance is a whole number, the exact radical form is also shown, such as √50 = 5√2.
Formula
d = √((x₂ − x₁)² + (y₂ − y₁)²) (3D: + (z₂ − z₁)²)
Questions people ask
Does the order of the points matter?
No. The differences are squared, so swapping the points gives the same distance.
What is Manhattan distance?
The distance traveling only along grid lines (like city blocks): |Δx| + |Δy|. It is always at least as long as the straight-line distance.
Can I use this for latitude and longitude?
Only for very short distances. Over larger areas the Earth's curvature matters, and you need the haversine formula instead.