What the distance formula is and when to use it
The distance formula finds the straight-line ("Euclidean") distance between two points in a coordinate plane or in 3D space. It is a direct application of the Pythagorean theorem: the difference in each coordinate axis forms a leg of a right triangle (or, in 3D, an extra dimension of separation), and the straight-line distance is the hypotenuse. This calculator automatically switches between the 2D and 3D versions of the formula — leave both Z fields blank for a flat, two-coordinate distance, or fill in Z1 and Z2 for a three-dimensional calculation.
Use it in geometry and algebra coursework to find the distance between two points on a graph, in physics or engineering to find the straight-line separation between two positions in space, or in any practical mapping context where you have two (x, y) or (x, y, z) coordinates and need the direct distance between them (not a path distance along roads or a grid).
The formula
2D: d = √[(x2 − x1)² + (y2 − y1)²]
3D: d = √[(x2 − x1)² + (y2 − y1)² + (z2 − z1)²]
- (x1, y1[, z1]) — the coordinates of the first point.
- (x2, y2[, z2]) — the coordinates of the second point.
- d — the straight-line distance between the two points, in whatever units the coordinates are measured in.
Worked example
For the 2D case, take Point 1 = (1, 2) and Point 2 = (4, 6). Δx = 4 − 1 = 3, Δy = 6 − 2 = 4. d = √(3² + 4²) = √(9 + 16) = √25 = 5 — a classic 3-4-5 right triangle, matching what the calculator returns for these inputs.
For the 3D case, take Point 1 = (0, 0, 0) and Point 2 = (2, 3, 6). Δx = 2, Δy = 3, Δz = 6. d = √(2² + 3² + 6²) = √(4 + 9 + 36) = √49 = 7, which the calculator returns when you fill in all three coordinates for both points.
Common mistakes and how to interpret the result
- Forgetting to leave Z blank for a 2D problem. If you only need the 2D distance, leave both Z1 and Z2 empty — entering a 0 in only one of them still triggers the 3D formula and can silently change your answer.
- Subtracting coordinates in the wrong order inconsistently. It doesn't matter whether you compute (x2 − x1) or (x1 − x2) since the difference is squared, but be consistent about which point is "1" and which is "2" when interpreting direction, not just distance.
- Confusing straight-line distance with path distance. This formula gives the direct ("as the crow flies") distance — it does not account for obstacles, roads, or grid-based movement (like city blocks), which require different distance metrics.
- Mixing units between coordinates. All coordinates must be in the same unit (all meters, all feet, etc.) — mixing units invalidates the result.