# 3D Coordinate Geometry - Distance

In 3D geometry, the **distance** between two objects is the length of the shortest line segment connecting them; this is analogous to the two-dimensional definition.

#### Contents

## Distance between 2 Points

In three-dimensional space, points are represented by their positions along the $x$-, $y$-, and $z$-axes, which are each perpendicular to one another; this is analogous to the 2d coordinate geometry interpretation in which each point is represented by only two coordinates (along the $x$- and $y$-axes).

In the figure above, the goal is to find the distance from the point $\left(x_{1},y_{1},z_{1}\right)$ to the point $\left(x_{2},y_{2},z_{2}\right).$ From the distance formula in two dimensions, the length of the the yellow line is

$\sqrt { { ({ x }_{ 2 }-{ x }_{ 1 }) }^{ 2 }+{ ({ y }_{ 2 }{ -y }_{ 1 }) }^{ 2 } }.$

Let $d$ be the distance from the point $\left(x_{1},y_{1},z_{1}\right)$ to $\left(x_{2},y_{2},z_{2}\right)$ (the red line, and the desired distance). Then, using the Pythagorean theorem,

$\begin{aligned} {d }^{ 2 }&= \left(\sqrt { { ({ x }_{ 2 }-{ x }_{ 1 }) }^{ 2 }+({ { y }_{ 2 }-{ y }_{ 1 }) }^{ 2 } } \right)^{ 2 }+{ ({ z }_{ 2 }-{ z }_{ 1 }) }^{ 2 }\\ \Rightarrow d&=\sqrt { { ({ x }_{ 2 }-{ x }_{ 1 }) }^{ 2 }+({ { y }_{ 2 }-{ y }_{ 1 }) }^{ 2 }+{ ({ z }_{ 2 }-{ z }_{ 1 }) }^{ 2 } }. \end{aligned}$

The above equation is the general form of the distance formula in 3D space. A special case is when the initial point is at the origin, which reduces the distance formula to the form

$d=\sqrt { { { x } }^{ 2 }+{ { y } }^{ 2 }+{ { z } }^{ 2 } },$

where $(x,y,z)$ is the terminal point. This equation extends the distance formula to 3D space.

Find the distance between the points $(2,-5,7)$ and $(3,4,5).$

From the distance formula, we have

$\begin{aligned} d&=\sqrt { { (3-2) }^{ 2 }+\big({ 4-(-5)\big) }^{ 2 }+{ (5-7) }^{ 2 } } \\ &=\sqrt { 1+81+4 } \\ &=\sqrt { 86 }.\ _\square \end{aligned}$

How far is the point $P=(3,4,5)$ from the origin?

Since the second point is the origin, or $(0,0,0)$, the distance is

$d=\sqrt{3^2+4^2+5^2}=5\sqrt{2}.\ _\square$

If the distance between the two points $(2,0,3)$ and $(-4,a,-1)$ is 8, what is the value of $a?$

From the distance formula,

$\begin{aligned} d&=\sqrt{\big(2-(-4)\big)^2+(0-a)^2+\big(3-(-1)\big)^2}\\ &=\sqrt{36+a^2+16}\\ &=\sqrt{52+a^2}\\ &=8. \end{aligned}$

Therefore,

$\begin{aligned} 52+a^2&=8^2\\&=64\\ a&=\pm2\sqrt{3}.\ _\square \end{aligned}$

## Distance between a Point and a Plane

Determining the distance between a point and a plane follows a similar strategy to determining the distance between a point and a line. Consider a plane defined by the equation

$ax + by + cz + d = 0$

and a point $(x_0, y_0, z_0)$ in space. Then the normal vector to the plane is

$\mathbf{v} = \begin{pmatrix}a\\b\\c\end{pmatrix}$

and the vector from an arbitrary point on the plane $(x,y,z)$ to the point is

$\mathbf{w} = \begin{pmatrix}x_0-x\\y_0-y\\z_0-z\end{pmatrix}.$

The distance from the point to the plane is the projection from $\mathbf{w}$ onto $\mathbf{v}$, or

$\begin{aligned} D &= |\text{proj}_{\mathbf{v}}\mathbf{w}| \\ &= \frac{|\mathbf{v} \cdot \mathbf{w}|}{|\mathbf{v}|} \\ &= \frac{|a(x_0-x)+b(y_0-y)+c(z_0-z)|}{\sqrt{a^2+b^2+c^2}} \\ &= \frac{|ax_0+by_0+cz_0-(ax+by+cz)|}{\sqrt{a^2+b^2+c^2}} \\ &= \frac{|ax_0+by_0+cz_0+d|}{\sqrt{a^2+b^2+c^2}}. \end{aligned}$

## Distance between 2 Skew Lines

The strategy behind determining the distance between 2 skew lines is to find two parallel planes passing through each line; this is because the distance between two planes is easy to calculate using vector projection. Furthermore, the normal vector to these 2 planes can be calculated using the cross product of the vectors representing the direction of the two lines.

In particular, suppose the two lines travel in the directions

$\begin{aligned} \mathbf{v}&=\begin{pmatrix}x_1&y_1&z_1\end{pmatrix}\\ \mathbf{w}&=\begin{pmatrix}x_2&y_2&z_2\end{pmatrix}, \end{aligned}$

then the normal to the planes can be calculated as

$\mathbf{n} = \mathbf{v} \times \mathbf{w} = \text{det}\begin{pmatrix}\hat{i}&\hat{j}&\hat{k}\\x_1&y_1&z_1\\x_2&y_2&z_2\end{pmatrix}$

and the distance between the two planes--which is the same as the distance between the two lines--can be calculated by projecting $\mathbf{n}$ onto $PQ$, where $P$ and $Q$ are points on the first and second lines, respectively.

Find the distance between the lines

$\frac{x+2}{2}=\frac{y-1}{3}=\frac{z}{1}\quad \text{and}\quad \frac{x-3}{-1}=\frac{y}{1}=\frac{z+1}{2}.$

Following the above strategy, the first line travels in the direction

$\mathbf{v}=\begin{pmatrix}2&3&1\end{pmatrix}$

and the second in the direction

$\mathbf{w}=\begin{pmatrix}-1&1&2\end{pmatrix}.$

Then

$\mathbf{n} = \mathbf{v} \times \mathbf{w} = \text{det}\begin{pmatrix}\hat{i}&\hat{j}&\hat{k}\\2&3&1\\-1&1&2\end{pmatrix}=\begin{pmatrix}5&-5&5\end{pmatrix}.$

Since $(-2, 1, 0)$ and $(3, 0, -1)$ are points on the two lines, respectively, the vector $PQ$ is $\begin{pmatrix}5&-1&-1\end{pmatrix}$. Then

$D=\big|\text{proj}_{\mathbf{n}}PQ\big|=\frac{\big|\mathbf{n} \cdot PQ\big|}{|\mathbf{n}|}=\frac{25}{5\sqrt{3}}=\frac{5\sqrt{3}}{3}.\ _\square$

## See Also

**Cite as:**3D Coordinate Geometry - Distance .

*Brilliant.org*. Retrieved from https://brilliant.org/wiki/3d-coordinate-geometry-distance/