StatGardenREF. DESK
Calculators/Maths/Distance & midpoint between two points (3D)
Maths

Distance & midpoint between two points (3D) calculator

Straight-line distance and midpoint between two points in 3D space (set z = 0 for 2D).

Published 6 August 2026 · Updated 23 September 2026

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

Formulad = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²); midpoint = ((x₁+x₂)/2, (y₁+y₂)/2, (z₁+z₂)/2)

Each coordinate difference is squared, the three are summed, and the square root taken. The midpoint averages each coordinate pair separately.

TermMeaning
Euclidean distanceStraight-line distance, which is what this calculates.
MidpointThe point halfway along the segment, found by averaging coordinates.
Pythagorean quadrupleFour whole numbers where three squared values sum to the fourth squared.

The inputs explained

FieldWhat 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).

From the origin
z coordinate (x = 3, y = 4)DistanceSquared distance
(3, 4, 0)5.00025.000
(3, 4, 12)13.000169.000
The point (3, 4, 0) sits exactly 5.000 away, the familiar 3-4-5 triangle. Adding a z of 12 gives exactly 13.000, since 9 plus 16 plus 144 is 169, which is 13 squared.

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.