3D Distance Calculator

Straight and grid distance between 3D points.

Math and PercentUpdated 2026-10-122 min read
3D Distance Calculator
Straight distance
...
Squared distance...
Grid walk...

What it does

Distance in space extends Pythagoras one step. Square each axis gap, add the three squares, and take the root. Warehouses, game maps, and survey offsets all reduce to that line once coordinates share a unit.

The tool above shows three views. From (0,0,0) to (3,4,12), straight distance is 13 m with 169 squared, while corridor walking needs 19 m. The imperial mirror reads 13 ft and 19 ft. Squared distance helps code that only compares nearness without paying for roots.

Units decide the label only. Meters or feet both work because the formula is unit free; mixing them breaks it. Flat work with equal heights reduces to the familiar 2D case, and identical points correctly give zero.

This page measures between two static points. It does not track moving targets, convert latitude and longitude, or correct map projections. For GPS, convert to local meters first.

How to use

  1. Pick metric (m) or imperial (ft).
  2. Enter the first point x1, y1, z1.
  3. Enter the second point x2, y2, z2.
  4. Read straight distance first.
  5. Read squared for code comparisons.
  6. Read grid walk for corridor routing.

Formula

d = root((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2). Squared = d^2. Manhattan = |dx| + |dy| + |dz|.
x1, y1, z1
First point coordinates in the shared unit.
x2, y2, z2
Second point coordinates in the same unit.
dx, dy, dz
Axis gaps whose squares sum to squared distance.

Euclidean metric in three dimensions with one shared unit. At identical points distance is zero. Very large coordinates near a billion need care with floating point squares.

Worked example

Example: (0,0,0) to (3,4,12)

Defaults: metric points (0,0,0) and (3,4,12). Imperial mirror uses feet. All six numbers share one unit.

  1. Inputs (metric default): (0,0,0) to (3,4,12).
  2. Deltas: 3, 4, 12.
  3. Squared: 9 plus 16 plus 144 is 169.
  4. Distance: root of 169 is 13 m.
  5. Grid walk: 3 plus 4 plus 12 is 19 m. Imperial mirror gives 13 ft and 19 ft. Tool shows the same.

Reference table

Checks
PointsStraightGrid
(0,0,0)-(3,4,12)13 m19 m
(1,2,3)-(4,6,12)10.3 m16 m
(0,0,0)-(1,1,1)1.73 m3 m
(0,0,0)-(6,8,0)10 m14 m
(2,3,5)-(2,3,9)4 m4 m

Limits

  • One shared unit. Mixed units fail.
  • Static points only. No motion or GPS.
  • Exact coordinates assumed. Survey error lives in inputs.
  • Huge values risk floating point squares.

Common mistakes

  • Mixing meters with feet in one pair.
  • Reading squared as distance.
  • Forgetting z on sloped sites.
  • Rounding deltas before the root.
  • Using grid walk for cable that runs straight.

Try it yourself

Quick checks. Answers sit tucked under each question.

(1,2,3) to (4,6,12)?

Deltas 3, 4, 9. Squares sum to 106. Distance is 10.3 m with 16 m grid walk.

(0,0,0) to (1,1,1)?

Deltas 1, 1, 1. Squares sum to 3. Distance is 1.73 m with 3 m grid walk.

Questions

What is the 3D distance formula?

Root of dx squared plus dy squared plus dz squared. Here root 169 is 13 m.

What is squared distance?

169 here. Squared avoids the root in comparisons and code.

What is Manhattan distance?

Sum of absolute deltas. Here 19 m of corridor walking.

Can I mix meters and feet?

No. All six numbers must share meters or feet. Convert first.

Does this work for flat maps?

Yes. Set z1 equal z2 and the formula reduces to 2D Pythagoras.

Should I round inputs first?

Use exact 13 m here. Rounding each delta first can shift the root.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.