I am trying to determine if a point is inside an irregular cuboid: by "irregular", I mean that the 4 points that make up one face are not necessarily co-planar. I found these answers: point inside rectangular area and point inside 3D cuboid but they seem to involve cases where the points comprising a face are co-planar. I have tried the following methods:
- decompose the cuboid into its 5 constituent tetrahedra and check if the point is inisde any of the tetrahedra
- decompose the cuboid into a polyhedron consisting of 12 triangles (2 per face) and check if the point is inside the polyhedron
- as 2 but with 4 triangles per face, using the mid-point of the face as a common vertex to the 4 triangles
- compute the convex hull and check if the point is inside the convex hull
- fit planes through each of the faces and check if the point lies between all 3 pairs of planes.
Unfortunately, I have some degenerate cases (illustrated below) for which none of these methods work: the colours represent either the tetrahedra or triangles used in methods 1 and 2.
For methods 1 and 2, the answer depends on which set of tetrahedra/triangles I choose: point P is inside the using the LH set of triangle/tetrahedra in the figure but outside using the RH set. There appear to be similar issues with the convex hull method, illustrated (not very well - apologies) by the dotted lines in the cross-sections. Method 3 does not work when the mid-point of (eg) the upper face is "deeper" than the mid-point of the lower face. Method 5 sometimes does not work in cases where the 4 vertices are not co-planar.
I am struggling with the concept of "inside" for some cases where the cuboid is highly distorted, which doesn't help with the question "point in cuboid" so any help would be greatly appreciated. Thanks!