CalcWorldHub
Math · CalcWorldHub

3D Distance Between Two Points: Formula and Examples

The straight-line distance from P₁=(1,2,3) to P₂=(4,6,3) is 5 coordinate units: the changes are 3, 4, and 0, so d=√(3²+4²+0²)=5. The 3D distance calculator applies that Euclidean formula to six coordinates. It measures the direct separation through space, not a route constrained by roads, walls, or axis-aligned movement.

Open calculator
Two points in a three-dimensional coordinate frame are joined by a straight diagonal, distinct from the dashed axis components.

Share this article

Two 3D points are connected by a diagonal, with separate x, y, and z coordinate changes shown as perpendicular components.
Resolve the displacement into three perpendicular coordinate changes.

What the distance represents

A point in a Cartesian 3D coordinate system is an ordered triple (x,y,z). Subtracting the first point from the second gives the displacement vector Δ=(x₂−x₁, y₂−y₁, z₂−z₁). The distance is the magnitude of this vector, so it is always nonnegative even when one or more coordinate changes are negative.

The formula extends the Pythagorean theorem: the three coordinate differences are perpendicular components, and their squares add. In a diagram, they form the legs of a right rectangular box and the straight-line distance is its space diagonal. This interpretation depends on orthogonal axes with a common scale, rather than an oblique or distorted coordinate grid.

Enter coordinates with compatible units

The form asks for Point 1 x, y, z followed by Point 2 x, y, z. Keep the order attached to each point. If coordinates represent meters, use meters for all six; if they represent a local engineering grid, the result is in that grid’s linear unit. The calculator does not convert units, project geographic latitude and longitude, or select a coordinate reference system.

Coordinates can be negative, zero, or positive. Their absolute positions do not determine the result by themselves: translating both points by the same vector leaves their separation unchanged. What matters is the difference on each axis. For measured locations, use a consistent datum, axis orientation, and precision before entering values.

Worked examples

Example 1 · a 3–4–5 displacement

Inputs: P₁=(1,2,3), P₂=(4,6,3).

Calculation: Δ=(3,4,0); d=√(3²+4²+0²)=√25.

Distance=5.0000; the endpoints are five coordinate units apart.

Example 2 · all three axes change

Inputs: P₁=(−2,1,4), P₂=(1,5,16).

Calculation: Δ=(3,4,12); d=√(9+16+144)=√169.

Distance=13.0000 coordinate units.

Points (1,2,3) and (4,6,3) differ by (3,4,0), giving a straight-line distance of 5.
A familiar right-triangle triple checks the spatial formula.

Calculate one coordinate component at a time

Compute Δx, Δy, and Δz before taking the root. This keeps sign and transcription errors visible. Squaring removes the sign only after the difference is formed; entering a coordinate into the wrong point can change the magnitude even when all six values look plausible. A quick independent check is to square each difference, add the three results, and then take the nonnegative square root.

The displayed distance is rounded to four decimal places, while the three signed coordinate changes are shown to three. Use those changes to verify which direction each component points, but do not reconstruct a high-precision answer from their rounded display. If the number will be used downstream, preserve the original coordinates and calculate from full precision.

Compare direct separation with other measures

Euclidean distance is the shortest straight segment between two points in ordinary 3D space. It differs from Manhattan distance, which adds the absolute axis changes as if a path must move along coordinate directions. For the same endpoints, Manhattan distance is at least as large as Euclidean distance; equality occurs when all nonzero movement lies on one axis.

Neither metric is a substitute for a route calculation. In a building, a straight segment might pass through a wall; in a street network, a vehicle follows connected roads; in terrain, slope may affect travel time. Choose the distance definition that matches the task rather than treating a coordinate formula as a physical path planner.

Units, scaling, and numerical care

If each coordinate is measured in centimeters, the result is in centimeters. Multiplying every coordinate by a scale factor multiplies the distance by its absolute value. Mixing meters on one axis with feet on another invalidates the geometry even though the arithmetic still returns a number; convert first. Likewise, longitude and latitude degrees are not equal-length Cartesian axes over the Earth.

Extremely large finite values can exceed the browser’s numeric range when squared or subtracted, and rounded output can hide tiny changes. For typical coordinate data the formula is stable and direct. For large geospatial datasets or uncertain measurements, a domain-specific library may use projection, scaling, or error handling that this six-input calculator does not provide.

A practical verification checklist

Before relying on a result, confirm the point labels, coordinate order, unit, and shared reference frame. Recompute the three differences separately, check that the sum of their squares is nonnegative, and compare the square root with the calculator display. Swapping Point 1 and Point 2 should leave the distance unchanged while reversing all three signed deltas.

For a simple consistency test, move only one coordinate by a known amount: changing x by 3 while y and z stay fixed must change the distance by exactly 3. If all coordinates are shifted equally at both endpoints, the output should not change. These tests catch common data-entry mistakes without requiring a second geometry package.

Sources and further reading

Share this article

Browse all articles · Calculator: 3D distance calculator