Check if a point (x0,y0,z0) lies inside a tetrahedron in Matlab

1k Views Asked by At

I have a tetrahedron defined by 4 points xi,yi,zi (i = 1 to 4)

To check if an arbitrary point x0,y0,z0 is inside the tetrahedron, I am taking the volume route i.e. I replace one of the points by x0,y0,z0 and obtain the volume of the tetrahedron. I say that if all the 4 computed volumes turn out to be positive, then it lies with in the tetrahedron. Is there a better way of doing this ?

Details of calculation here

1

There are 1 best solutions below

0
On

To know if a point is inside a tetrahedron the best/more robust way is computing on which side of each of the 4 planes is, and compare that to a point that is know to be inside.

Step by step:

  1. Compute geometric centre of tetrahedron
  2. Compute each of the 4 plane equations, in the form of ax+by+cz+d=0. (i.e. compute a,b,c,d from the points).
  3. Plug geometry centre of tetrahedron in each plane equation (x,y,z), and store the sign of the result (it will be positive on one side, negative on the other, zero if the point lies in the plane)
  4. Plug desired point in each of the plane equations. If the sign of the result is the same for all 4 as the geometric centre, then it is inside of the equation