Distance Calculator (3D). Enter the coordinates of two points in 3D space — X1, Y1, Z1 for the first point and X2, Y2, Z2 for the second — and this 3D Distance Calculator computes the straight-line distance between them using the 3D distance formula. You also get the individual axis differences (ΔX, ΔY, ΔZ) as supporting outputs. Also try the calculate Rise Over Run.
The Distance Calculator (3D) gives you the straight-line distance between two points when each one is described by three numbers. You enter x, y and z coordinates from a Cartesian coordinate system and get the length of the joining line. The method suits CAD checks, game objects and geometry homework alike. See also our Distance Calculator (2D).
What is the 3D distance formula?
The distance formula extends the Pythagorean theorem into three dimensions. In coordinate geometry, your first point is (x1, y1, z1) and your second is (x2, y2, z2):
Picture a right triangle on the floor, built from the x gap and the y gap. Its hypotenuse is how far apart the points look from above. Stand a second triangle on that edge, using the height gap as the other side, and the new hypotenuse is a straight line through the air.
The three differences are squared before they are added, so a negative gap turns positive. You can swap which of the two points counts as first without changing the result. The value under the square root never drops below zero.
The output is a scalar: it tells you how far, not which way. Some sources call the setting a 3D coordinate plane, although it has three axes. Keep all six inputs in one unit.
How to use the Distance Calculator (3D)
The tool needs six numbers. To use any 3D distance calculator and verify it by hand:
Enter the coordinates of your first point.
Enter the second point in the same unit. Integers and decimals both work, with or without a minus sign.
Subtract the x-coordinates, then the y-coordinates, then the z values.
Square each gap, add the three squares and take the square root.
This finds the distance between two points at any scale. A distance calculator 3D result is only as precise as your measurements.
Worked example in a 3D coordinate space
Suppose you need the distance between two points surveyed on a hillside, in metres: antenna mount A at (12.4, −3.7, 5.2) and mount B at (−6.8, 14.9, 23.6). Here is the math:
Axis
Mount A
Mount B
Gap (B − A)
Gap squared
x
12.4
−6.8
−19.2
368.64
y
−3.7
14.9
18.6
345.96
z
5.2
23.6
18.4
338.56
The squares total 1,053.16, so \(d = \sqrt{1053.16} \approx 32.452\) m. Notice how the x-values straddle zero: 12.4 to −6.8 is a 19.2 m gap, not 5.6 m. Dropping that sign is the easiest mistake to make. Report one decimal place (32.5 m) if your readings carry only one.Squared gaps add up before the single square root.
Midpoint of the straight-line distance
A three-dimensional distance calculator answers how far, while the midpoint answers where halfway is. Average each pair of values:
For the two mounts, the midpoint is (2.8, 5.6, 14.4), about 16.226 m from each end. You might place a cable support there.
Special cases of distance between points
When your points share x and y, the answer is the absolute value of the z gap, like reading a number line. Whole-number gaps of 2, 3 and 6 give exactly 7, and gaps of 6, 6 and 7 give 11. These cousins of Pythagorean triples make handy test inputs.
Distance from the origin
Set the second point to (0, 0, 0) and the formula shrinks to \(d = \sqrt{x^2 + y^2 + z^2}\). Mount A therefore sits about 13.946 m from the origin of the survey grid.
2D distance on a coordinate plane
When both heights are equal, the third term vanishes and you are left with ordinary 2D distance. Applied to the mounts as if seen on a 2D plane from above:
Horizontal change (along x): −19.2 m
Vertical change (up the graph, along y): 18.6 m
Flat result: 26.732 m, with a slope of about −0.97
The true separation is 32.452 m, so a floor plan alone would come up 5.72 m short. Ordering cable from that drawing would leave you short.The floor diagonal and height gap form the second triangle.
Checking a drone's straight-line distance to a mast
Say you fly inspection drones and need to know, before launch, how far the aircraft will be from you at a mast fitting. Your site plan uses a local coordinate system in metres, so you type the home point (3.5, −2.1, 1.4) first, then the fitting (212.8, 146.3, 87.9), into the Distance Calculator (3D).
The gaps are 209.3, 148.4 and 86.5 m. Their squares, 43,806.49, 22,022.56 and 7,482.25, total 73,311.30, and the square root gives a straight-line distance of 270.761 m. I would redo that by hand once: the flat 2D distance is 256.572 m, and combining it with 86.5 returns the same Euclidean distance.
The catch is that a drone may not fly that line. If it climbs vertically and then travels level, the path is 86.5 + 256.572 = 343.072 m, which is 72.31 m longer. For battery planning you would budget 686.1 m for the round trip, not 541.5 m.
Next, test which input matters. Change one value and run the three-dimensional distance calculator again:
Fitting coordinates
Straight line
Change
As surveyed
270.761 m
none
z raised 30 m to 117.9
281.782 m
+11.0 m
x moved 30 m to 242.8
294.566 m
+23.8 m
Here a 30 m horizontal change in x moves the result about twice as far as the same vertical change in z, because x holds the largest gap. The z gap also gives a first check against the 120 m cap in the EU open category: 86.5 m is under it. That rule measures from the closest ground, though, so lower ground at the mast means a greater height than your inputs show. Take every z value from one reference level, and keep all coordinates in metres, since one value in feet would wreck the distance between two points.
Shortest distance on Earth from latitude and longitude
Latitude and longitude are angles, so never type them into x, y and z boxes as though they were lengths. A road map reports driving distance, which follows streets, while a line through 3D space tunnels under the ground.
Great-circle distance and the haversine method
Over the surface of a sphere, the shortest route follows a great circle. The haversine formula works once your angles are converted to radians. This formula is:
Using a mean radius R of 6,371 km, Lisbon (38.7223, −9.1393) to Reykjavik (64.1466, −21.9426) gives a great-circle distance of about 2,950.1 km. Convert both cities to x, y and z on that sphere, and the chord through the Earth is about 2,923.8 km, so the surface route is 26.3 km longer.Surface arc against the chord beneath it.
Euclidean distance compared with other measures
The straight-line result is the Euclidean distance, what a taut string would read. Decide how you need to measure distance between two points before you trust a number.
Manhattan distance and vector magnitude
Manhattan distance adds the absolute gaps, as a pipe locked to right-angle runs would. Vector magnitude applies the same root to the gaps (−19.2, 18.6, 18.4) and matches the Euclidean figure.
Measure for mounts A and B
Use it when
Result
Flat, from above
Height does not matter
26.732 m
Euclidean
A direct span is possible
32.452 m
Manhattan
Runs follow the three axes
56.2 m
A related but different job is the distance from a point to a plane, such as the clearance between a sensor and a sloped roof. It uses that surface's equation, \(ax + by + cz + k = 0\), in \(|ax_0 + by_0 + cz_0 + k| / \sqrt{a^2 + b^2 + c^2}\). If you know the closest spot on the surface, enter it and the sensor as your two sets of coordinates for the same clearance. You might also find our Direction Vector d = n₁ × n₂ — Line of Intersection of Two Planes useful.