I am trying to compute all possible intersections between a tetrahedron lying in 4D space and a non-centered 3D hyperplane. Because of my lack of visualization (obviously), and for computer rendering purposes, I am using a computational approach.
My algorithm fills an array with vertices, and builds the resulting intersection as being the convex polygon or polyhedron uniquely defined by said vertices, on the basis that the intersection of a convex set with a hyperplane is also convex.
Here is the workflow of the algorithm :
- Determine which of the tetrahedron's points lie in opposite half-spaces
- If all points are in the same half-space, terminate with an empty intersection
- If at least one point is inside the hyperplane, then add to the array all the vertices that are inside the hyperplane. This could be 1, 2, 3 or 4 vertices
- Then, for each edge that intersects the hyperplane (ie edges for which the two vertices lie in opposite half-spaces), add to the array the intersection between that edge and the hyperplane
Although I have not written a rigorous proof for this, I find empirically that you only get points, lines, triangles, quadrilaterals or tetrahedras out of this algorithm (or at least, I have never encountered a counter-example).
The problem resides in this visualisation of a unit hypercube rotating around its center on the XZ and ZW canonical planes by equal angles, in that order (WebM video) :
The principle of the visualisation is a simple application of the aforementioned algorithm. The hypercube is decomposed in 4D tetrahedras, which are subsequently intersected with a 3D hyperplane, which is defined by the position of the camera and the direction of its (3D) viewing frustum. The resulting intersections, being 3D objects, are directly displayed on the screen with no further transformation. The pixels colored with different shades of blue are forward-facing faces, and the black pixels are backward-facing faces.
As you can see, the 3D model becomes non-convex from time to time, as it looks like a face or two are "forgotten" and we can see the "inside", back-facing faces behind. This leads to my question : am I forgetting any scenario in my intersection algorithm that may lead to the omission of some of the 3D objects making up the hypercube ? Although I have not yet totally outruled a flaw in my rendering process, I believe I have done enough checking and trying to think the error is in this algorithm.