Wikipedia:Reference desk/Archives/Mathematics/2008 June 30

= June 30 =

point inside tetrahedron
Quick before its too late - a question.

Is there a very easy way to determine if a point lies inside an irregular tetrahedron defined by its four points?87.102.86.73 (talk) 23:58, 30 June 2008 (UTC)


 * Yes. Call your test point P.  For each face, view it from the outside and label the points A, B, C in counter-clockwise (right-hand) order.  $$\vec{v_1} = \overline{AB}, \vec{v_2} = \overline{AC}, \vec{v_P} = \overline{AP}$$.  Now if $$(\vec{v_1} \times \vec{v_2}) \cdot \vec{v_P} > 0$$ then the point is outside the tetrahedron.  If the point doesn't test outside for any of the faces, then it is inside or on the surface (I think you can figure out that edge case).  --Prestidigitator (talk) 01:44, 1 July 2008 (UTC)
 * Yes cross product and dot products -that's the simplest I could find. Easier than solving for the scalars in the expression P=A + pAB +qAC +rAD where AB is the vector from A to B etc87.102.86.73 (talk) 09:47, 1 July 2008 (UTC)
 * Thank you very much.87.102.86.73 (talk) 09:55, 1 July 2008 (UTC)

It's not necessarily easy to define 'outside' and 'counterclockwise' for any given four points, esp. when you need to implement the calculations in some automatic routine like a computer program. The more general method would be to calculate similar expressions for the tetrahedron's fourth point and your test point and compare their signs: Repeat calculations, having each vertex as D — a tertrahedron is a common part (intersection) of four half-spaces, so four positive results give you a positive answer to your question. --CiaPan (talk) 12:22, 1 July 2008 (UTC)
 * name any of four given points D, then name remaining three A, B and C;
 * calculate vectors $$\vec{v_1} = AB, \vec{v_2} = AC, \vec{v_D} = AD, \vec{v_P} = AP$$
 * calculate vector $$\vec{N} = \vec{v_1} \times \vec{v_2}$$ (perpendicular to the ABC plane) and verify if $$\vec{v_P} \cdot \vec{N}$$ and $$\vec{v_D} \cdot \vec{N}$$ are both positive or both negative – if so, points P and D are at the same side of ABC plane, otherwise they are at opposite sides.
 * Nice touch.. but I don't really agree with It's not necessarily easy to define 'outside' and 'counterclockwise' for any given four points - it is quite easy for 4 points.. (if I ignore the rotation ... and noting the possibility of an 'inverted tetrahedron')
 * (ABC,BCD,BDA,CAD are one such set - I hope - it is tricky)
 * note I'd calculate the 4 cross product vectors, and the 4 dot products.. I only note the sign of the dot products.. IF all 4 signs are the same then it's inside..
 * taken for a general convex shell made up of triangles the method you describe will save me time of working that out, for a little extra work later on.. Thanks.87.102.86.73 (talk) 23:03, 1 July 2008 (UTC)