StatGardenREF. DESK
Calculators/Geometry/Distance Formula (2D & 3D Points)
Geometry

Distance Formula (2D & 3D Points) calculator

Straight-line distance between two coordinate points, in a plane or in 3D space.

What this calculator does

The distance formula gives the straight-line distance between two points from their coordinates alone, no ruler needed. In two dimensions it is Pythagoras in disguise: the gap in x and the gap in y form the two short sides of a right triangle, and the distance between the points is the hypotenuse. In three dimensions the same idea extends with a third term for the gap in z.

This is a distance calculator for coordinate points specifically, not a unit converter. Enter two points, choose 2D or 3D, and the distance comes back along with the individual x, y (and z) gaps the calculation is built from.

The formula

Formula2D: d = √((x₂−x₁)² + (y₂−y₁)²) · 3D: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²)

For two points, the differences in each coordinate are squared, added together, and the square root taken. In 2D that is √((x₂−x₁)² + (y₂−y₁)²); in 3D a (z₂−z₁)² term is added under the same square root. Squaring removes the sign of each difference, so it does not matter which point is labelled 1 and which is labelled 2.

TermMeaning
CoordinatesThe x, y (and z, in 3D) position of each point.
Δx, Δy, ΔzThe difference between the two points along each axis: the second point's coordinate minus the first.
DistanceThe straight-line (Euclidean) distance between the two points, the square root of the sum of the squared differences.

The inputs explained

FieldWhat to enter
DimensionsWhether the two points have just x and y coordinates (2D) or also a z coordinate (3D).
x₁The x coordinate of the first point.
y₁The y coordinate of the first point.
z₁ (3D only)The z coordinate of the first point, used only in 3D mode.
x₂The x coordinate of the second point.
y₂The y coordinate of the second point.
z₂ (3D only)The z coordinate of the second point, used only in 3D mode.

When to use it

Working the formula for distance by hand

A student checking homework, or anyone who wants to see the formula for distance applied to their own numbers rather than trusting a textbook example, gets every intermediate step: the x gap, the y gap, and the final square root.

Finding distance in 3D space

Coordinates with a z axis show up in 3D modelling, physics problems and some mapping work, and the plain 2D formula does not account for the extra dimension without the added z term.

Checking how far apart two points on a graph are

Given the coordinates of two plotted points, the distance calculator returns the length of the line segment between them without needing to measure the graph itself.

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.

Distance from the origin to a range of 2D points

The origin against a spread of second points, each a simple whole-number step away.

Fixed point (0, 0), second point varied
Second point xDistance
(3, 4)6.708
(4, 4)7.211
(5, 4)7.810
(6, 4)8.485
(8, 4)10.000
(12, 4)13.416
With y₂ fixed at 4, the point (3, 4) sits exactly 5 units from the origin, the classic 3-4-5 right triangle; as x₂ grows the distance grows too, but not in a straight one-to-one step, since it is the hypotenuse of a widening triangle.

Adding a third dimension to the same pair of points

The same x and y coordinates, compared with and without a z gap of 5 added in 3D mode.

2D versus 3D distance, same x and y gap
ModeDistance
2D (x, y only)5.000
3D (x, y, z)7.071
In 2D the same x and y gap gives the familiar 3-4-5 distance of 5; adding a z gap of 5 in 3D mode increases the distance to about 7.07, since the extra dimension adds its own squared term under the root rather than simply adding on top.

Questions

What is the distance formula?

It is Pythagoras applied to coordinates: d = √((x₂−x₁)² + (y₂−y₁)²) for two points on a plane, with a matching (z₂−z₁)² term added under the root for points in 3D space.

Is a distance calculator the same as a distance converter?

No. A distance converter changes a length from one unit to another, such as miles to kilometres. This calculator works out a straight-line distance between two coordinate points, which is a different, geometric question.

What is the formula for distance in 3D?

d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²), the same squared-differences-under-a-root pattern as 2D, extended with one more term for the z axis.

Does it matter which point is point 1 and which is point 2?

No. Each difference is squared before being added, which removes the sign, so swapping the two points around gives the same distance either way.

For the midpoint, slope and line equation between two points as well as the distance, see the distance, midpoint and slope calculator. For distance and travel time between two named places, see the length and distance converter.