The distance between two points in space is the length of the straight segment joining them, the same idea as on a flat graph with a third coordinate for height or depth. It is the basic measurement behind 3D modeling and CAD, robot and drone paths, game collision checks and the bond lengths chemists compute from atom positions. This calculator takes two points (x₁, y₁, z₁) and (x₂, y₂, z₂) and returns the distance, its exact square-root form for whole-number inputs, the midpoint and the direction angles.
How to use the 3D distance calculator
- Under Point 1, enter x₁, y₁ and z₁.
- Under Point 2, enter x₂, y₂ and z₂. Negatives and decimals are allowed.
- Read the Distance. If all six coordinates are integers and the answer isn’t whole, the exact value (for example 2√34) is shown beneath it.
- The other rows give Δx, Δy, Δz, the squared distance d², the Midpoint, the Distance in the xy-plane (the ground distance, ignoring z), the Manhattan distance and the Angle with x axis, y axis and z axis. A box diagram shows |Δx|, |Δy| and |Δz| as edges with the distance as its space diagonal.
The result is in whatever unit the coordinates use, so keep all three axes in the same unit.
3D distance formula
Picture the two points as opposite corners of a box. The floor diagonal comes from the Pythagorean theorem, √(Δx² + Δy²). That diagonal and the vertical edge Δz form a second right triangle standing on the floor, and its hypotenuse is the distance you want. Squaring the floor diagonal undoes its square root, which is why the three squared differences simply add.
Direction angles
The angles α, β and γ describe which way the segment points. When z is “up”, 90° − γ is the angle of climb above the horizontal.
Worked example: a drone flight
A survey drone hovers at (10, 20, 30) in meters, measured east, north and up from its launch pad. Its next waypoint is (70, 100, 45). How far is the straight-line flight?
- Δx = 70 − 10 = 60, Δy = 100 − 20 = 80, Δz = 45 − 30 = 15.
- Ground distance: √(60² + 80²) = √10,000 = 100 m.
- Flight distance: √(100² + 15²) = √10,225 = 5√409 ≈ 101.12 m.
- Angle with the z-axis: 81.47°, so the drone climbs at 90° − 81.47° ≈ 8.53°.
- Angles with the x- and y-axes: 53.60° and 37.71°. The midpoint, (40, 60, 37.5), is a handy check-in position halfway along.
Box and room diagonals
The space diagonal of a box with edges l, w and h is √(l² + w² + h²). It is the longest straight rod that fits inside, which tells you whether a ladder, pipe or curtain rod will go into a room, a crate or a truck. A 4 × 3 × 2 ft crate, for instance, has a floor diagonal of exactly 5 ft but a space diagonal of √29 ≈ 5.39 ft, so a thin 5¼-ft rod fits, though only on the slant.
| Edges l × w × h | d² | Diagonal |
|---|---|---|
| 1 × 1 × 1 | 3 | √3 ≈ 1.732051 |
| 1 × 2 × 2 | 9 | 3 |
| 2 × 3 × 6 | 49 | 7 |
| 3 × 4 × 12 | 169 | 13 |
| 12 × 9 × 8 | 289 | 17 |
| 16 × 12 × 9 | 481 | √481 ≈ 21.931712 |
Rows with whole-number diagonals are Pythagorean quadruples, the 3D cousins of the 3-4-5 triangle. A cube’s diagonal makes the same angle, about 54.7356°, with all three axes; physicists call it the magic angle.
Common mistakes
- Mixed units. GPS altitude is often reported in feet while a local grid is in meters. Convert first, or the z term is badly over- or under-weighted.
- Raw latitude and longitude. They are angles, not lengths. Convert them to a local east–north grid in meters before using this formula, or use a great-circle method for long distances.
- Dropping a sign. Subtract in the same order for every axis. Squaring hides a sign error in the distance, but the direction angles will be wrong.
For two coordinates only, use the distance between two points calculator. For the volume and surface of the box itself, see the rectangular prism calculator or the cube calculator.
Frequently asked questions
What is the 3D distance formula?
d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). It is the flat distance formula with a third squared difference added. For (1, 2, 3) and (4, 6, 15) the differences are 3, 4 and 12, so d = √169 = 13.
How is the 3D formula related to the Pythagorean theorem?
It applies the theorem twice. The x and y differences give the distance across the floor, and that distance together with the z difference gives the full diagonal. The calculator shows this two-step view in its working.
What are direction angles?
They are the angles the segment makes with the positive x, y and z axes, found from cos α = Δx ÷ d, cos β = Δy ÷ d and cos γ = Δz ÷ d. The squares of the three cosines always add up to 1. An angle above 90° means that coordinate decreases from point 1 to point 2.
How do I find the diagonal of a box or a room?
Put one corner at (0, 0, 0) and the opposite corner at (length, width, height); the distance between them is √(l² + w² + h²). A room 12 ft by 9 ft with an 8 ft ceiling has a corner-to-corner diagonal of exactly 17 ft.
Can I enter negative or decimal coordinates?
Yes. Only the differences between coordinates matter, and they are squared, so the distance is never negative. The exact square-root form appears only when all six coordinates are whole numbers.