3D Distance Calculator

Find the straight-line distance between two points in three-dimensional space.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

The 3D distance calculator finds the exact straight-line (Euclidean) distance between any two points in three-dimensional space. Give it the (x, y, z) coordinates of both points and it instantly shows the distance, the full step-by-step working, and a small isometric diagram of the two points on the axes. You can also reverse the calculation: choose any one of the six coordinates as the unknown, supply the target distance, and the tool finds the two possible values for that coordinate.

This is the go-to tool for geometry homework, computer graphics, game development, CAD and engineering, robotics path planning, or any calculation that involves a gap through open 3-D space.

How it works

The 3-D distance formula is a direct generalisation of the 2-D Pythagorean theorem. Given two points P1(x₁, y₁, z₁) and P2(x₂, y₂, z₂), the differences along each axis are:

dx = x₂ − x₁, dy = y₂ − y₁, dz = z₂ − z₁

These three gaps form the legs of a right-angled box. The space diagonal — the straight-line distance — follows from squaring each leg, summing, and taking the square root:

d = sqrt(dx² + dy² + dz²)

Because every term is squared, the sign of each difference and the order of the two points never affect the result. The distance is always a non-negative number.

The solve-for mode inverts the formula. For example, if you know the distance d and want to find x₁, you rearrange to:

x₁ = x₂ ± sqrt(d² − dy² − dz²)

This has two solutions (the ± sign) because a sphere of radius d centred on P2 intersects the line parallel to the x-axis at two points. The calculator shows both; you choose whichever matches your context. If d² − dy² − dz² is negative, no real solution exists — the target distance is too small for the remaining two-axis gaps.

Worked example

Find the distance between P1(1, 2, 3) and P2(4, 6, 3):

dx = 4 − 1 = 3 dy = 6 − 2 = 4 dz = 3 − 3 = 0 d = sqrt(3² + 4² + 0²) = sqrt(9 + 16 + 0) = sqrt(25) = 5

The z-coordinates are equal, so this collapses to the classic 3-4-5 right triangle in the xy-plane.

Now a fully three-dimensional example — P1(0, 0, 0) and P2(1, 2, 2):

dx = 1, dy = 2, dz = 2 d = sqrt(1 + 4 + 4) = sqrt(9) = 3

P1P2Distance
(0, 0, 0)(1, 2, 2)3
(1, 2, 3)(4, 6, 3)5
(0, 0, 0)(2, 4, 4)6
(-1, -1, -1)(2, 3, 3)sqrt(41) approx 6.403

Formula note

The formula d = sqrt((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²) is the L2 norm (Euclidean norm) of the displacement vector from P1 to P2. It generalises to any number of dimensions: for n-dimensional space simply sum n squared differences under the square root. The 2-D version (no z term) is the standard school distance formula; the 3-D version adds one more squared difference to account for depth.

Ad placeholder (rectangle)