What this calculator does
Distance in three dimensions is Pythagoras applied twice: once across the base plane and once vertically. The result is the square root of the sum of the three squared differences.
Some coordinate triples give whole numbers, which is satisfying when they appear. A displacement of (3, 4, 12) has a distance of exactly 13.000, one of the Pythagorean quadruples, and (3, 4, 0) gives the familiar 5.000.
The formula
Each coordinate difference is squared, the three are summed, and the square root taken. The midpoint averages each coordinate pair separately.
| Term | Meaning |
|---|---|
| Euclidean distance | Straight-line distance, which is what this calculates. |
| Midpoint | The point halfway along the segment, found by averaging coordinates. |
| Pythagorean quadruple | Four whole numbers where three squared values sum to the fourth squared. |
The inputs explained
| Field | What to enter |
|---|---|
| x₁ | First point, x coordinate. |
| y₁ | First point, y coordinate. |
| z₁ | First point, z coordinate. Set both z values to zero for a 2D problem. |
| x₂ | Second point, x coordinate. |
| y₂ | Second point, y coordinate. |
| z₂ | Second point, z coordinate. |
When to use it
Measuring in 3D space
Graphics, physics and engineering all need straight-line distance between points.
Finding a centre point
The midpoint is the average of the two positions.
Working in 2D
Setting both z coordinates to zero reduces this to the plane case.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
Which displacements give whole distances?
Three endpoints measured from (0, 0, 0).
| z coordinate (x = 3, y = 4) | Distance | Squared distance |
|---|---|---|
| (3, 4, 0) | 5.000 | 25.000 |
| (3, 4, 12) | 13.000 | 169.000 |
Questions
Why is this just Pythagoras twice?
Because the displacement forms the diagonal of a rectangular box. Applying Pythagoras across the base gives the base diagonal, and applying it again with the height gives the full space diagonal.
What is a Pythagorean quadruple?
Four whole numbers where the squares of three sum to the square of the fourth, such as 3, 4, 12 and 13. They are the three-dimensional analogue of Pythagorean triples and are considerably rarer.
Does this work in higher dimensions?
Yes, unchanged in principle. Euclidean distance in any number of dimensions is the square root of the sum of squared differences, however many coordinates there are.
Why report the squared distance?
Because it avoids a square root, and many algorithms only need to compare distances rather than measure them. Comparing squared distances gives the same ordering far more cheaply.
For vector length from the origin, see the vector magnitude calculator. For distance to a plane, see the point to plane distance calculator.