Enter the xyz coordinates of point 1 and point 2 to find the distance between them in 3D space. The changes in x, y and z are shown too.
Table of Contents
-
What you can do on this page
-
What is this calculation used for?
-
How to Use
-
Formulas and figures
-
Symbols and terms
-
Good to know before you start
-
How to calculate it in Excel
-
How to calculate it in Google Sheets
-
How to calculate it in Python
-
How to write it in LaTeX and other math languages (copy and paste)
-
How to have ChatGPT do the calculation
-
DataChef Features
-
Related Features
-
NumberChef Calculators List
What you can do on this page
- Enter the xyz coordinates of two points in space (3D), and you get the distance \(d\) between them on the spot
- Along with the distance, it also finds the change in x \(\Delta x\), the change in y \(\Delta y\) and the change in z \(\Delta z\)
- The result is also shown in a 3D figure you can rotate with the mouse, so you can see that the distance is the length of the line segment joining the two points (the diagonal of a box)
- A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
What is this calculation used for?
In a 3D game, the positions of characters, bullets and items are kept as (x, y, z) coordinates, and the game decides "it is a hit when the distance is less than a set amount" or "an enemy notices you when you come within a set distance". For example, if your character is at (1, 1, 1) and an enemy is at (2, 3, 3), the distance is \(\sqrt{1^2 + 2^2 + 2^2} = 3\). Repeating this calculation every frame is how distance checks in 3D games work.
It is just the distance formula from 2D games with one more term for \(z\).
A drone's position can be given by three numbers: how far away it is horizontally (x and y) and its height (z). If a drone is 240 ft east and 320 ft north of the pilot, at a height of 300 ft, the straight-line distance to it is \(\sqrt{240^2 + 320^2 + 300^2} = \sqrt{250000} = 500\) ft.
This distance in space is what you use to think about radio range and how far away you can still see the drone.
In 3D CAD, positions such as the centers of holes and the corners of a part are given as coordinates in space. The distance between two points that are diagonally apart in space, which is often not written on the drawing, can be found from the differences in coordinates with the formula on this page. For example, two points 3 in apart across, 4 in apart in depth and 12 in apart vertically are \(\sqrt{3^2 + 4^2 + 12^2} = 13\) in apart.
It is an everyday calculation in making things, such as estimating the length of a brace or the shortest route for pipes and wires.
In chemistry, the position of each atom in a molecule is recorded as coordinates in space (protein databases use this format too). Once you know the coordinates of two atoms, the distance between them (a bond length, or how close two atoms are) is found with exactly the formula on this page.
It is a basic calculation behind drug discovery and materials development, for example when checking whether a candidate drug molecule fits well into its target.
Formulas and figures
Symbols and terms
Symbols
| \(d\) | dee | The distance between the two points in space, from the first letter of "distance". |
| \((x_1, y_1, z_1)\), \((x_2, y_2, z_2)\) | x sub one, y sub one, z sub one | The coordinates of the two points in space. \(x\) and \(y\) give the position on a flat plane, and \(z\) gives the height. The small number at the lower right (the subscript) tells the first point from the second. |
| \(\Delta x\), \(\Delta y\), \(\Delta z\) | delta x, delta y, delta z | The change (the difference of the coordinates). \(\Delta\) (delta) is a Greek letter that stands for "change" or "difference": \(\Delta x = x_2 - x_1\), \(\Delta y = y_2 - y_1\) and \(\Delta z = z_2 - z_1\). |
| \(\ell\) | ell | The symbol used in this explanation for the length of the floor diagonal of the box. \(\ell^2 = \Delta x^2 + \Delta y^2\); it is the in-between step when using the Pythagorean theorem twice. |
| \(\sqrt{\phantom{a}}\) | square root (radical sign) | The sign for the square root (the number that gives this number when squared). \(\sqrt{9} = 3\) (because 3² = 9). In the 3D distance formula, too, you take the square root only once, at the end. |
Terms
| 3D coordinate space | Space with a z-axis for height added to the x-axis and the y-axis, where the position of a point is given by three numbers (x, y, z). It is plane (2D) coordinates with one more coordinate for height. |
| coordinates | Numbers that give the position of a point. In space there are three, as in the point (2, 3, 3): 2 in the x-direction, 3 in the y-direction and 3 in the z-direction (height). |
| line segment | A straight line that joins two points, with those points as its ends. The distance between two points is the length of this line segment. |
| Pythagorean theorem | The theorem that in a right triangle, the sum of the squares of the two legs equals the square of the hypotenuse. The 3D distance formula uses this theorem twice in a row. It is taught in Grade 8. |
| diagonal of a box | The line that joins opposite corners of a rectangular box (rectangular prism), passing through the inside. For a box with length a, width b and height c, the diagonal is \(\sqrt{a^2 + b^2 + c^2}\) long. The distance between two points in space is the same calculation. |
| Euclidean distance | The formal name for the straight-line distance between two points that this page calculates. Not only in 3D but also in data analysis and AI, this name is often used for the basic way to measure how close points are. |
| dimension | How many numbers you need to give a position. A line is 1-dimensional (the number line), a plane is 2-dimensional (x, y), and space is 3-dimensional (x, y, z). Each extra dimension adds just one more term under the square root; the shape of the distance formula stays the same. |
Good to know before you start
Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
If you get stuck, going back over these topics is the fastest way forward.
| The coordinate plane (Grade 6) |
|
| Operations with positive and negative numbers (Grade 7) |
|
| Square roots (Grade 8) |
|
| The Pythagorean theorem (Grade 8) |
|
| Solid figures and 3D coordinates (middle school and high school) |
|
How to calculate it in Excel
| Point 1 x-coordinate x₁ | 1 |
| Point 1 y-coordinate y₁ | 1 |
| Point 1 z-coordinate z₁ | 1 |
| Point 2 x-coordinate x₂ | 2 |
| Point 2 y-coordinate y₂ | 3 |
| Point 2 z-coordinate z₂ | 3 |
| Distance between the points d | =SQRT((B4-B1)^2+(B5-B2)^2+(B6-B3)^2) |
| Point 1 x-coordinate x₁ | 0 |
| Point 1 y-coordinate y₁ | 0 |
| Point 1 z-coordinate z₁ | 0 |
| Point 2 x-coordinate x₂ | 3 |
| Point 2 y-coordinate y₂ | 4 |
| Point 2 z-coordinate z₂ | 12 |
| Change in x Δx | =B4-B1 |
| Change in y Δy | =B5-B2 |
| Change in z Δz | =B6-B3 |
| Floor diagonal ℓ=√(Δx²+Δy²) | =SQRT(B7^2+B8^2) |
| Distance between the points d=√(ℓ²+Δz²) | =SQRT(B10^2+B9^2) |
"SQRT(…)" is the square root, and "^2" is squared.
The first table gives the distance 3. The second table starts from Δx = 3, Δy = 4 and Δz = 12, finds the floor diagonal ℓ = 5 first and then the distance d = 13, so you can also see the values along the way when the Pythagorean theorem is used twice.
How to calculate it in Google Sheets
| Point 1 x-coordinate x₁ | 1 |
| Point 1 y-coordinate y₁ | 1 |
| Point 1 z-coordinate z₁ | 1 |
| Point 2 x-coordinate x₂ | 2 |
| Point 2 y-coordinate y₂ | 3 |
| Point 2 z-coordinate z₂ | 3 |
| Distance between the points d | =SQRT((B4-B1)^2+(B5-B2)^2+(B6-B3)^2) |
| Point 1 x-coordinate x₁ | 0 |
| Point 1 y-coordinate y₁ | 0 |
| Point 1 z-coordinate z₁ | 0 |
| Point 2 x-coordinate x₂ | 3 |
| Point 2 y-coordinate y₂ | 4 |
| Point 2 z-coordinate z₂ | 12 |
| Change in x Δx | =B4-B1 |
| Change in y Δy | =B5-B2 |
| Change in z Δz | =B6-B3 |
| Floor diagonal ℓ=√(Δx²+Δy²) | =SQRT(B7^2+B8^2) |
| Distance between the points d=√(ℓ²+Δz²) | =SQRT(B10^2+B9^2) |
How to calculate it in Python
import math
x1, y1, z1 = 1.0, 1.0, 1.0 # coordinates of point 1
x2, y2, z2 = 2.0, 3.0, 3.0 # coordinates of point 2
delta_x = x2 - x1 # change in x
delta_y = y2 - y1 # change in y
delta_z = z2 - z1 # change in z
distance = math.sqrt(delta_x**2 + delta_y**2 + delta_z**2) # distance between the points
print(f"Change in x Δx: {delta_x}")
print(f"Change in y Δy: {delta_y}")
print(f"Change in z Δz: {delta_z}")
print(f"Distance between the points d: {distance}")
# The same calculation can be written in one line with math.dist (Python 3.8 or later)
print(f"Check with math.dist: {math.dist((x1, y1, z1), (x2, y2, z2))}")
How to write it in LaTeX and other math languages (copy and paste)
d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>d</mi>
<mo>=</mo>
<msqrt>
<mrow>
<msup>
<mrow><mo>(</mo><msub><mi>x</mi><mn>2</mn></msub><mo>−</mo><msub><mi>x</mi><mn>1</mn></msub><mo>)</mo></mrow>
<mn>2</mn>
</msup>
<mo>+</mo>
<msup>
<mrow><mo>(</mo><msub><mi>y</mi><mn>2</mn></msub><mo>−</mo><msub><mi>y</mi><mn>1</mn></msub><mo>)</mo></mrow>
<mn>2</mn>
</msup>
<mo>+</mo>
<msup>
<mrow><mo>(</mo><msub><mi>z</mi><mn>2</mn></msub><mo>−</mo><msub><mi>z</mi><mn>1</mn></msub><mo>)</mo></mrow>
<mn>2</mn>
</msup>
</mrow>
</msqrt>
</mrow>
</math>
d = sqrt((x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2)
Sqrt[(x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2]
d := sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2);
d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2);
d = √((x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2)
Δx² + Δy² + Δz² = d²
\Delta x^2 + \Delta y^2 + \Delta z^2 = d^2
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<msup><mrow><mi mathvariant="normal">Δ</mi><mi>x</mi></mrow><mn>2</mn></msup>
<mo>+</mo>
<msup><mrow><mi mathvariant="normal">Δ</mi><mi>y</mi></mrow><mn>2</mn></msup>
<mo>+</mo>
<msup><mrow><mi mathvariant="normal">Δ</mi><mi>z</mi></mrow><mn>2</mn></msup>
<mo>=</mo>
<msup><mi>d</mi><mn>2</mn></msup>
</mrow>
</math>
(Delta x)^2 + (Delta y)^2 + (Delta z)^2 = d^2
dx^2 + dy^2 + dz^2 == d^2
dx^2 + dy^2 + dz^2 = d^2;
dx^2 + dy^2 + dz^2 == d^2
Δx^2 + Δy^2 + Δz^2 = d^2
How to have ChatGPT do the calculation
You are a math calculation assistant. Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing). For the two points (1, 1, 1) and (2, 3, 3) in 3D space (coordinate space), find each of the following: 1. The distance d between the two points (use the 3D distance formula d = √((x2−x1)² + (y2−y1)² + (z2−z1)²)) 2. The change in x Δx, the change in y Δy and the change in z Δz Show the formulas you used and the numbers from the execution result.
How to Use
-
1Enter your numbersType the numbers you want to calculate with into the input fields
-
2CalculatePress the "Calculate" button
-
3Check the resultThe result appears on the spot. The same page also explains the idea behind the calculation and the formula
DataChef Features
No technical knowledge required.
Intuitive and user-friendly operation.
Can be used without registering personal information.
Automatic file deletion by clicking "download".
and rapid file conversion.
No attribution required.
No need to contact us for commercial use permission.
