3D Distance Calculator

The distance between two points in space is d = √(Δx² + Δy² + Δz²). Between (1, 2, 3) and (4, 6, 15) the displacement is (3, 4, 12), so the distance is 13, the midpoint is (2.5, 4, 9) and the distance measured on the xy-plane alone is 5.

Last updated · By · Runs in your browser, nothing is uploaded

Result

Step-by-Step Solution

Enter your values above to see the full working.

What Is the 3D Distance Formula?

The 3D distance formula extends the familiar Pythagorean theorem into three dimensions. To find the straight-line distance between two points that each have an x, y and z coordinate, you take the difference in each coordinate, square the three differences, add them and take the square root. It gives the length of the shortest path through space, the “as the crow flies” distance.

The idea works because the three-dimensional distance is built from two right triangles. First, the horizontal distance on the ground (the xy-plane) is √(Δx² + Δy²). Then that ground distance and the vertical difference Δz form a second right triangle whose hypotenuse is the full 3D distance.

Results for (1, 2, 3) and (4, 6, 15)

QuantityFormulaValue
Displacement(x₂ − x₁, y₂ − y₁, z₂ − z₁)(3, 4, 12)
Ground distance (xy-plane)√(Δx² + Δy²)5
3D distance√(Δx² + Δy² + Δz²)13
Midpointaverage of each coordinate(2.5, 4, 9)

Notice that 5, 12 and 13 form a Pythagorean triple: a ground distance of 5 and a climb of 12 give a straight-line distance of 13.

Distance Formula in Three Dimensions

d = √[ (x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)² ] Ground distance = √[ (x₂ − x₁)² + (y₂ − y₁)² ] Midpoint = ( (x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2, (z₁ + z₂) ÷ 2 )
  • (x₁, y₁, z₁) and (x₂, y₂, z₂) are the two points.
  • The differences can be taken in either order, because they are squared.
  • The distance is in the same unit as the coordinates.
  • In two dimensions, set the z-coordinates equal and you recover the ordinary distance formula.
  • The distance from the origin to a point is its vector magnitude.

How Is It Calculated? Worked Examples

(1, 2, 3) to (4, 6, 15)

  1. Δx = 3, Δy = 4, Δz = 12.
  2. Squares: 9 + 16 + 144 = 169.
  3. d = √169 = 13.
  4. Ground distance: √(9 + 16) = 5.
  5. Angle of climb: arctan(12 ÷ 5) = 67.4° above the horizontal.
  6. Midpoint: (2.5, 4, 9).

The Diagonal of a Room

A room is 5 m long, 4 m wide and 3 m high. The longest straight line that fits inside runs from one floor corner to the opposite ceiling corner: √(25 + 16 + 9) = √50 ≈ 7.07 m. Along the floor alone, the diagonal is √41 = 6.40 m.

Distance from the Origin

The point (2, 3, 6) is √(4 + 9 + 36) = √49 = 7 units from the origin.

A Cube’s Space Diagonal

For a unit cube from (0, 0, 0) to (1, 1, 1), the distance is √3 ≈ 1.732.

A Drone Flight

A drone flies from a launch point to a spot 30 m east, 40 m north and 120 m above it. The horizontal distance is 50 m, and the straight-line distance is √(900 + 1,600 + 14,400) = 130 m, another multiple of the 5-12-13 triple.

How to Use This 3D Distance Calculator

  1. Enter the coordinates (x₁, y₁, z₁) of the first point.
  2. Enter the coordinates (x₂, y₂, z₂) of the second point.
  3. Read the 3D distance, the midpoint, the displacement and the ground distance.

Use the same unit for all coordinates. For 2D points, enter 0 for both z values.

Where 3D Distance Is Used

  • Engineering and construction: lengths of braces, cables and pipes between 3D points.
  • Computer graphics, games and animation: distances between objects, camera ranges and collision tests.
  • Robotics and drones: path length and range to a target.
  • Chemistry and biology: distances between atoms in a molecule, using 3D coordinates.
  • Surveying and GIS: slope distance between points with different elevations.

Distances Between Atoms

Chemists use the same formula for bond lengths. Two atoms at (0, 0, 0) and (1.2, 0.8, 0.9) ångströms are √(1.44 + 0.64 + 0.81) = √2.89 = 1.7 Å apart.

What Are the Most Common Mistakes With the 3D Distance Calculator?

  • Forgetting the z-term. Using only x and y gives the ground distance, not the 3D distance.
  • Not squaring or not taking the root. Both are needed.
  • Mixed units. Height in feet and ground distance in metres will ruin the result.
  • Using latitude and longitude as flat coordinates. On the globe, use great-circle formulas.
  • Mixing up distance and displacement. The displacement is a vector, the distance is its length.
  • Assuming the path is straight. The formula gives the shortest, straight-line distance only.

Where Can You Verify These Formulas?

The definitions and formulas on this page follow standard references. Check them against these sources:

Built and maintained by S. Dilshan. Found a mistake? Email [email protected] with the page address.

Frequently Asked Questions

What is the formula for distance in 3D?

d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²].

What is the distance between (1, 2, 3) and (4, 6, 15)?

13 units, since the displacement is (3, 4, 12) and 9 + 16 + 144 = 169.

How does the 3D formula relate to the Pythagorean theorem?

It applies the theorem twice: once for the ground distance and once with the vertical difference.

How do I find the midpoint in 3D?

Average each coordinate: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2, (z₁ + z₂) ÷ 2).

What is the space diagonal of a box?

√(l² + w² + h²), the 3D distance between opposite corners.

Can I use it for two-dimensional points?

Yes. Set both z-coordinates to the same value, such as 0.