I am trying to write C++ code to find the intersection points of a segment intersecting a tetrahedron. I reduced the problem like this:
- For each face of the tetrahedron (a triangle), find the intersection point of the line segment. Then, I have three cases: a) The segment doesn't intersect any face - thus either the segment is entirely in the tetrahedron or completely outside. b) The segment only intersects one face. Then I just need to determine the side of the segment that is in the tetrahedron and I get the two points that are in the tetrahedron. c) The segment intersects two faces.
I am having trouble implementing this algorithm. Here are the issues:
- If the segment and triangle are in the same plane, how do I find the intersection points?
- How can I determine if the segment lies on one of the edges of the tetrahedron?
Thanks.