---
slug: 3d-distance-calculator
title: "3D Distance Calculator"
category: geometry
updated: 2026-11-18
canonical: https://calcseed.com/c/geometry/3d-distance-calculator/
html: /c/geometry/3d-distance-calculator/
---

# 3D Distance Calculator

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

## Quick answer

**Quick answer:** with the default inputs (0, 0, 0, 3), the distance is **7.07**. Change any input to update the result.

## Default calculation

Values computed by this calculator at exactly the default inputs listed below.

### Inputs (defaults)

| Input | Value | Unit |
| --- | --- | --- |
| x1 | 0 |  |
| y1 | 0 |  |
| z1 | 0 |  |
| x2 | 3 |  |
| y2 | 4 |  |
| z2 | 5 |  |

### Outputs at these defaults

| Output | Value | Unit |
| --- | --- | --- |
| Distance | 7.07107 |  |

## Formula

```text
d = &radic;((x2−x1)² + (y2−y1)² + (z2−z1)²)
```

## Inputs

| Variable | Type | Unit | Default |
| --- | --- | --- | --- |
| x1 | number |  | 0 |
| y1 | number |  | 0 |
| z1 | number |  | 0 |
| x2 | number |  | 3 |
| y2 | number |  | 4 |
| z2 | number |  | 5 |

## Outputs

| Result | Format |
| --- | --- |
| Distance | primary |
| Distance | number |

## How it works

### What this calculator measures

Enter two points as x, y, z coordinates and the calculator returns the straight-line distance between them — the length of an imaginary taut string through space, not the walking distance along axes. The result carries whatever units the coordinates use: meters in give meters out.

### The formula: Pythagoras twice

The 3D distance formula is the Pythagorean theorem applied twice. First, the horizontal plane: the run (x2 − x1) and the depth (y2 − y1) combine into a flat distance of &radic;(dx² + dy²). That flat distance and the vertical rise (z2 − z1) then form a second right triangle whose hypotenuse is the true space distance, producing the single expression below.

#### Order of the points does not matter

Squaring makes the order of the two points irrelevant: (x2 − x1)² equals (x1 − x2)², so swapping point 1 and point 2 changes nothing. Each squared difference is also always positive, which is why the value under the root can never be negative and the formula never fails.

### Worked example with the defaults

The calculator loads with point 1 at the origin (0, 0, 0) and point 2 at (3, 4, 5). The differences are dx = 3, dy = 4, dz = 5, so d = &radic;(9 + 16 + 25) = &radic;50 = **7.0711**. Notice what the flat part does on its own: &radic;(9 + 16) = 5, the classic 3-4-5 triangle, and the z-drop of 5 stretches that 5-unit ground distance to 7.0711 through space.

Compare that with travel along the axes. A path that moves 3, then 4, then 5 units along the coordinate directions covers 12 units — the Manhattan distance — while the straight shot covers 7.0711. The gap between the two is why delivery drones and diagonal corridors save so much distance over grid travel, and the ratio depends on how the movement is split among the axes.

### Distances for familiar point pairs

| Point 1 | Point 2 | Differences (dx, dy, dz) | Distance |
| --- | --- | --- | --- |
| (0, 0, 0) | (3, 4, 5) | (3, 4, 5) | 7.0711 |
| (0, 0, 0) | (3, 4, 0) | (3, 4, 0) | 5.0000 |
| (0, 0, 0) | (1, 1, 1) | (1, 1, 1) | 1.7321 |
| (1, 2, 3) | (4, 6, 15) | (3, 4, 12) | 13.0000 |
| (0, 0, 0) | (2, 6, 9) | (2, 6, 9) | 11.0000 |

The second row is the pure 2D case: with both z values equal, the third term vanishes and the formula collapses to the flat Pythagorean theorem, giving exactly 5. The third row is the space diagonal of a unit cube, always &radic;3 ≈ 1.7321 — and for a cube of any side s, the corner-to-corner distance is s&radic;3, so a 10-foot cube measures 17.3205 feet across its body diagonal. The fourth row hides a triple: 3, 4, 12 under one root yields exactly 13. Whole-number results exist in three dimensions too — differences of 2, 3, 6 span exactly 7, and 4, 4, 7 span exactly 9 — though they are rarer than the flat triples because three squares rarely sum to another square.

### Where the formula earns its keep

#### Games: millions of checks per frame

Games and graphics run this formula constantly: every collision check, camera focus, and character-to-enemy range test is a 3D distance, which is why engines cache squared distances and avoid the square root when they only need to compare sizes. The squared distance dx² + dy² + dz² ranks points identically to the distance itself, and skipping the root saves real computation at millions of checks per frame.

#### Engineering, drones, and layout

Engineering uses it for tolerance and layout: the true gap between two mounting holes in a fixture, the reach of a robot arm between stations, and the straight-line cable run between equipment racks all come from these six coordinate reads. Drone flight planning uses it between waypoints, and warehouse modeling contrasts the straight-line 7.0711 with the aisle-following 12 to estimate how much picking time a better layout could recover.

### What moves the number

- Every axis contributes squared, so no single coordinate dominates: (3, 4, 12) spans 13 while (3, 4, 5) spans 7.0711.
- The z term extends, not replaces, the 2D answer: flat distance 5 grows to 7.0711 when z separates by 5.
- Squaring removes signs — points at −3 and +3 on the same axis are 6 apart, and the formula handles negatives automatically.
- Doubling every difference doubles the distance, since the formula is homogeneous: &radic;(4 × 50) = 2 &radic;50.
- The smallest possible result is zero, when the two points coincide.

### Common mistakes

- Dropping the z term for 3D points, which returns the shadow distance on the floor instead of the space distance.
- Adding the coordinate differences instead of squaring them — that computes the Manhattan distance of 12 rather than 7.0711 for the defaults.
- Mixing units across axes, such as meters for x and y but feet for z.
- Taking the square root before summing the squares, which underestimates every result.
- Treating a negative coordinate difference as an error; squaring erases the sign, so (0 − 5)² and 5² are the same 25.

## FAQ

### How is 3D distance different from 2D distance?

It adds a third squared term under the same root. The defaults give &radic;(9 + 16 + 25) = 7.0711, while the same points with z = 0 would give 5.

### Can I use this for 2D points?

Yes. Set both z coordinates to the same value — usually zero — and the formula reduces to the flat Pythagorean theorem: (0, 0, 0) to (3, 4, 0) is exactly 5.

### What is the distance formula in three dimensions?

d = &radic;((x2 − x1)² + (y2 − y1)² + (z2 − z1)²), the Pythagorean theorem extended with a third leg.

### What is the distance from (0, 0, 0) to (3, 4, 5)?

&radic;50 ≈ 7.0711. The flat 3-4-5 ground distance of 5 gains about 2.07 units from the 5-unit vertical rise.

### How long is the space diagonal of a cube?

Side times &radic;3: a unit cube measures 1.7321 corner to corner, and a 10-foot cube measures 17.3205 feet across its body diagonal.

### Does it matter which point I enter first?

No. Squaring makes the differences positive either way, so (3, 4, 5) to the origin and the origin to (3, 4, 5) both return 7.0711.

### Why is the straight distance shorter than the axis path?

Axis travel accumulates every difference, 3 + 4 + 5 = 12 for the defaults, while the straight line exploits the hypotenuse shortcut for 7.0711 — about 41 percent shorter.

### What units does the result use?

Whatever the coordinates use. Points in meters return meters; points in feet return feet. All three axes must share one unit.

### Can the distance be negative?

No. The value under the root is a sum of squares, never negative, and a square root returns zero at minimum — which happens only when the points coincide.

### Why do game engines compare squared distances?

Because ranking by dx² + dy² + dz² gives the same order as the true distance without the costly square root — for the defaults, 50 ranks identically to 7.0711.

## Method and sources

Methodology: Formulas are the standard closed-form expressions of Euclidean geometry, exact for the given inputs.

Last updated: 2026-11-18.
- 3D distance formula derived from the Pythagorean theorem.
