3D Distance Calculator

Distance—
Distance in the xy-plane—
Height difference (|dz|)—

How 3D Distance Calculator is calculated: Distance = √((x2 − x1)² + (y2 − y1)² + (z2 − z1)²)

What is distance in three dimensions?

Distance in three dimensions is the straight-line length between two points in space, measured through the air rather than along the ground. It is the three-dimensional version of the familiar two-dimensional distance, with a third coordinate added for height. Two points on the same floor have the same 3D distance as their 2D distance, but two points on different floors are further apart in 3D than on a flat map, because the height difference adds to the length.

This calculator finds the 3D distance from the coordinates of two points, and it also shows the distance in the xy-plane and the height difference separately. For the two-dimensional case, a distance calculator covers the same Pythagorean idea with one fewer coordinate.

Everything on this page runs in your browser, so the numbers you type never leave your device. There is no sign-up, no upload and no waiting for a server. Change any input and the results update straight away, which makes it easy to test a few values side by side before you decide anything. You can also use it offline once the page has loaded, because the calculation needs no connection at all.

How 3D distance is calculated

The distance is the square root of the sum of the squares of the differences in each coordinate. Subtract the x-coordinates and square the result, do the same for y and for z, add the three squares together, and take the square root. That is the Pythagorean theorem applied twice: first in the xy-plane, to get the flat distance, and then in the vertical plane, combining the flat distance with the height difference.

Each point is given by three coordinates: x, y and z. The x and y coordinates are the position on the flat plane, and z is the height. All six numbers must be in the same unit, and the answer comes out in that unit. The order of the two points does not matter, because the differences are squared, so swapping them gives the same distance.

The distance is the headline number, in the same unit as the inputs, and it is the straight-line length between the points. The distance in the xy-plane is the flat distance, ignoring height, which is what a map would show. The height difference is the absolute difference in z, which is how much higher one point is than the other.

Read the results together, not in isolation. The main result answers the headline question, but the supporting rows explain how it was reached, and they are the first place to look when a number surprises you. If the main result moves more than you expected when you change an input, check the supporting rows: they usually show which part of the calculation moved, and whether the change came from the input you intended or from a different one.

The height difference, explained

The height difference is the part of 3D distance that has no equivalent in two dimensions, and it is the one people most often forget. Two points directly above each other have the same x and y, so their flat distance is zero, but their 3D distance is the height difference. Two points on different floors of a building are further apart than the floor plan suggests, because the vertical gap adds to the length.

The height difference enters the formula squared, just like the other differences, so a large height difference dominates the distance. A point 12 units above another, with a flat distance of 5 units, is 13 units away in 3D, because 5, 12 and 13 form a Pythagorean triple. That is the same 3-4-5 idea extended into three dimensions, and it is a useful check.

When the height difference is small compared with the flat distance, it changes the 3D distance only slightly. A flat distance of 100 units with a height difference of 1 unit gives a 3D distance of about 100.005 units, which is barely different. When the height difference is large, it dominates: a flat distance of 1 unit with a height difference of 100 units gives a 3D distance of about 100.005 units as well, but now the height is doing the work.

A worked example: (1, 2, 3) to (4, 6, 3)

Take two points, the first at (1, 2, 3) and the second at (4, 6, 3). They are on the same level, because both have z equal to 3, so the height difference is zero and the 3D distance should match the flat distance.

The differences are 3 in x, 4 in y and 0 in z. Square them to get 9, 16 and 0, add them to get 25, and take the square root to get a distance of 5.00 units. The distance in the xy-plane is 5.00 units, and the height difference is 0.00 units.

A distance of 5.00 units is the classic 3-4-5 triangle, and the fact that the height difference is zero confirms the two points are on the same level. If the second point had been at z equal to 15 instead of 3, the height difference would have been 12, and the 3D distance would have been 13, which is the 5-12-13 triple built on top of the 3-4-5 base.

Who uses 3D distance

3D modellers and game developers use it constantly, because every object in a game or a model sits in three-dimensional space. The distance between a character and an enemy, between a camera and a target, or between two vertices of a mesh is a 3D distance, and it decides visibility, collision and rendering.

Engineers and surveyors use it for points at different heights, such as the distance between two floors, between a drone and a target, or between two points on a terrain model. A flat map gives the wrong answer whenever height is involved, and the 3D distance corrects it.

Astronomers use it for stars, where the three coordinates are positions in space, and the distance decides how far apart two stars really are, as opposed to how far apart they look on the sky. A Pythagorean theorem calculator is the tool for the right-angled triangles that the formula is built from.

Treat the answers as a working figure, not as a final decision. The calculator applies the formula exactly as stated, but it cannot know the details of your situation: the exact rate, the precise measurements, or the rule that applies in your case. Use the result to narrow the question, then confirm the final number with the source that governs it, whether that is a textbook, a professional, or an official table. For a related calculation, the triangle area calculator covers the next number most people need after this one.

3D distance vs 2D distance

2D distance uses two coordinates and one application of the Pythagorean theorem. 3D distance uses three coordinates and two applications: first in the plane, then with the height. The 3D distance is always at least as large as the 2D distance, and it equals the 2D distance exactly when the height difference is zero.

In practice, the difference matters whenever height is involved. A drone 100 metres away horizontally and 100 metres above you is about 141 metres away in 3D, not 100 metres, and that difference decides whether it is in range. For points on the same floor, the two distances agree, and the simpler 2D calculation is enough.

Use whichever tool matches the question in front of you. When you need both answers, run the two tools with the same inputs and compare the results line by line; the difference between them is usually the decision itself. If the two tools disagree, check the inputs first, because a different input explains most disagreements.

Common mistakes with 3D distance

The first is forgetting the z-coordinate entirely, which gives the flat distance instead of the 3D distance. The second is forgetting to square the differences, which gives a meaningless sum of signed numbers.

The third is forgetting the square root at the end, which gives the squared distance instead of the distance. The fourth is mixing units, such as x and y in metres and z in centimetres.

Check your answer in two ways: the 3D distance must be at least as large as the flat distance, and at least as large as the height difference. If it is smaller than either, the calculation is wrong. For a quick check, points (0,0,0) and (3,4,12) are 13 units apart.

How to use this 3D distance calculator

To use it, enter point 1: x; enter point 1: y; enter point 1: z; enter point 2: x, then read the results box at the top. The main result is highlighted, and the other rows give the supporting figures. If an answer looks wrong, check the inputs first: a misplaced decimal or a wrong unit is the usual cause, not the formula.

Enter the three coordinates of each point, all in the same unit, and read the distance. The order of the points does not matter. If the height difference is zero, the answer should match the 2D distance, which is a good check that the inputs are right.

Your figures stay on your own device because the whole calculation happens in the browser. Nothing is uploaded, nothing is stored, and there is no account to create. That makes it safe to try realistic numbers, including the ones you would not want to paste into a random website. It also means the tool works the same way on a phone, a tablet or a computer, with nothing to install.

Frequently Asked Questions

The distance between (x1, y1, z1) and (x2, y2, z2) is the square root of (x2 minus x1) squared plus (y2 minus y1) squared plus (z2 minus z1) squared. It is the Pythagorean theorem applied twice: once in the xy-plane, and once with the height.

3D distance adds the height difference to the calculation. It is always at least as large as the 2D distance, and it equals the 2D distance exactly when the two points are at the same height. For points on different floors, the 3D distance is the correct measure.

The differences are 3, 4 and 12, whose squares are 9, 16 and 144, adding to 169. The square root of 169 is 13, so the distance is 13 units. This is the 5-12-13 triple built on the 3-4-5 triangle in the plane.

No. The differences are squared, so swapping the two points gives the same squares and the same distance. The distance from A to B is the same as the distance from B to A, in two dimensions and in three.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.