is created by David Witten, a mathematics and computer science student at Vanderbilt University. For more information, see the "About" page.

Distance between Objects in 3-Space

Distance between Two Points

MathJax TeX Test Page This is pretty straightforward. We just use the pythagorean theorem. So, it equals: $$\sqrt{(x_2-x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$$

Distance between a Point and a Line

MathJax TeX Test Page There are many ways to do this, but this way makes a lot of sense to me.

So, you have your point P, and all you need to do is pick an arbitrary point on the line, Q. You also have the vector part of your line, $< a,b,c>$. An important thing to remember is the cross product of two vectors equals the area of the parallelogram made by those two vectors. The area of a parallelogram also equals the base $\cdot$ height.
Notice that the area equals $< a,b,c> * $ the distance to the line. So, we could write an equation for the distance from a point to a line. $$\dfrac{|\vec{PQ}\times{}< a,b,c>|}{|< a,b,c>|}$$ The numerator is the area of the parallelogram, and the denominator is the base. So, the quotient is the distance to the line.


MathJax TeX Test Page Find the distance between the point $(2, 7, -1)$ and the line $< x, y,z> = (1,2,3) + t\cdot <-1, 5, 8>$ $$$$ Step one: Let's pick a random point on the line. Let's just do $(1,2,3)$. So, the vector from our point and the point on the line is $\vec{PQ} = < -1, -5, 4>$ $$$$ Step two: Take the cross product between $\vec{PQ}$ and $< -1,5,8>$ and find its magnitude. $$||< -1, -5, 4> \times <-1, 5, 8>|| = ||< -60, 4, -10>|| = 60.959$$ $$$$ Step three: Divide by the magnitude of the line vector. $$\text{Distance to the line = } \frac{60.959}{\sqrt{(-1)^2 + 5^2 + 8^2}} = 6.425$$

Distance between a Point and a Plane

This is a little bit different, here we have to use something called a projection, where one vector "casts a shadow" onto another vector.

P is an arbitrary point, and Q is the one we care about.&nbsp;

P is an arbitrary point, and Q is the one we care about. 

MathJax TeX Test Page Basically, what we have to do is create a right triangle. We know the normal vector (perpendicular to the plane), $\vec{n}$. We have a vector $\vec{PQ}$ which connects from a point on the plane to another point in space. That is the hypotenuse of the triangle. So, to find out how long the normal vector side of the triangle is, we have to do $ \vec{PQ} \cdot \cos(\theta)$. Now, we don't know the angle, but we don't need to know it. The dot product of $\vec{a}$ and $\vec{b}$ = $|a||b|\cos(\theta)$. So $\vec{PQ}*\cos(\theta)$ becomes $$\dfrac{|\vec{PQ}\cdot \vec{n}|}{||\vec{n}||}$$. We can simplify this a lot though. Let's say P (on the plane) is $(x_0,y_0,z_0)$, and Q (in space) is $(x_1,y_1,z_1)$, PQ is $< x_1-x_0, y_1-y_0, z_1-z_0>$. So, we could rewrite our last equation as $$\dfrac{|A(x_1-x_0) + B(y_1-y_0) + C(x_1-x_0)|}{\sqrt{A^2 + B^2 + C^2}}$$. Recall from my article about planes, $D = -Ax_0 - By_0 - Cz_0$. We could rewrite this one last time as $$\dfrac{|Ax_1 + By_1 + Cz_1 + D|}{\sqrt{A^2 + B^2 + C^2}}$$


MathJax TeX Test Page Find the distance from the point (2,8,5) to the plane x - 2y - 2z = 1 $$=\dfrac{|1(2) - 2(8) - 2(5) -1|}{\sqrt{1 + (-2)^2 + (-2)^2}} = \dfrac{|-25|}{\sqrt{9}} = \dfrac{25}{3}$$

Distance between Two Skew Lines

MathJax TeX Test Page This isn't too bad. The only important thing to realize is for every two skew lines, there exists a plane that is parallel to both of them. If you construct that plane on one of the lines, all you have to do is take the distance between a point and a plane, which is very easy. Now, because the plane is parallel to both lines, the normal vector is orthogonal to both direction vectors. The only operation that gives us a vector perpendicular to two different vectors is the cross product. Now, we have a normal vector $< A,B,C>$ and we must pick a point on one of the lines to define our plane. Last, we pick a point on the other line, and take the distance between the plane and that point.

Distance between Two Parallel Planes

First, you must verify the planes are parallel. The way to do this is to check if the normal vectors are the same or are multiples of each other. Then, you pick a point on one plane, and find the distance between that point and the other plane. 

David Witten

Converting Between Coordinate Systems