Let's say we have 3 points: (-2,7,4), (-4,5,2), (3,8,5) and we want to see if a fourth point, (2,6,3), is in the plane that the previous 3 points made. How would I go about doing this?
How do you detect if a point is in a plane?
3 Answers
Let $(x_1, y_1, z_1)$, $(x_2, y_2, z_2)$, and $(x_3, y_3, z_3)$ be the three given points, and $(a,b,c)$ be the fourth. A little linear algebra shows that $(a,b,c)$ is in the plane if and only if the following matrix has rank 2 (assuming of course that the three given points are not collinear):
$$ \left[\begin{array}{ccc} x_2-x_1 & y_2-y_1 & z_2-z_1 \\ x_3-x_1 & y_3-y_1 & z_3-z_1 \\ a-x_1 & b-y_1 & c-z_1 \end{array}\right] $$
Hope this helps!
-
0I'm still fairly new to linear algebra. What exactly is a rank 2 matrix? (On a side note, if I know what a rank 2 is, this will be exactly what I'm looking for! :) ) – 2012-10-27
-
0Rank is the maximum number of linearly independent rows. Instead of detecting the rank explicitly for this question, it suffices to check that the determinant is 0. – 2012-10-27
-
0Alright. Thanks a lot! – 2012-10-27
-
0Just FYI: Rank determination is difficult to do numerically. – 2012-10-27
-
0To be honest, the main reason I'm using this method is because I'm using this in a program I'm writing (a 3D engine, in fact) and I already have a matrix system set in place, so this seemed like (and is) the easiest method to implement. – 2012-10-27
-
2I would caution against using rank determination in a numerical setting if you are using floating point calculations. The method I suggested is slightly more costly, but returns a meaningful number (distance to the plane) which you can compare with some $\epsilon >0$ to decide if it is 'close enough'. – 2012-10-27
-
0Of course, since the determinant is also a continuous function from matrix space to $\mathbb{R}$, you can always compare the determinant to some tolerance $\epsilon$ in order to estimate "close enough." – 2012-10-27
-
0Neither scheme (rank determination or the cross-product version in my answer) is numerically stable (particularly as $x_2-x_1$ and $x_3-x_1$ become close to parallel). (See http://www.cs.berkeley.edu/~wkahan/MathH110/Cross.pdf for a lot of detail.) However,the scheme below has a possibly useful geometric interpretation. – 2012-10-27
Let $x_1,x_2,x_3 \in \mathbb{R}^3$ be three non-collinear points. Let $n = (x_2-x_1) \times (x_3-x_1)$, $\hat{n} = \frac{1}{\|n\|} n$, and $d = \langle x_1, \hat{n} \rangle$. Then $|\langle x, \hat{n} \rangle -d|$ is the distance from the point $x$ to the plane spanned by $x_1,x_2,x_3 $. Typically, you need to decide numerically whether or not the point is actually on the plane.
In your case we can perform the calculations exactly: $n = (0, -8, 8)^T$, $\hat{n} = \frac{1}{8\sqrt{2}} (0, -8, 8)^T$, $d = -\frac{3}{\sqrt{2}}$.
If we let $x = (2,6,3)^T$, we have $\langle x, \hat{n} \rangle = -\frac{3}{\sqrt{2}}$, hence the distance to the plane = $|-\frac{3}{\sqrt{2}}+\frac{3}{\sqrt{2}}| = 0$, so the point is on the plane.
In fact, with a little more calculation, you can show that $x = \frac{1}{8} (-11 x_1 + 9 x_2 + 10 x_3)$, and since the coefficients sum to $1$, $x$ lies in what is known as the affine hull of $x_1,x_2,x_3$, which in this case is the plane containing the points.
To complete the connection, you can show that $\langle x-x_1, n \rangle = \det A$, where $A = \begin{bmatrix} x_2-x_1 & x_3-x_1 & x - x_1 \end{bmatrix}$. Note that $A$ is the transpose of the matrix in Shaun's answer. The catch here is that you need to scale by $\frac{1}{\|n\|}$ to get a numerically meaningful answer.
Use the given three points to find the equation of the plane, $ax+by+cz=d$. Then plug in the fourth point and see if it satisfies the equation.
-
0And what exactly is d in that equation? – 2012-10-27
-
0The equation of a plane can be expressed as $ax+by+cz=d$, where $a,b,c,d$ are real numbers. Another useful version is $a(x-x_o)+b(y-y_o)+c(z-z_o)=0$, where $(x_o,y_o,z_o)$ is a point in the plane and $\langle a,b,c \rangle$ is the normal vector of the plane. – 2012-10-27