Let $P$ be a indexable set(array) of points in $\mathbb{R}^3$ s.t. $P = \{p_0,p_1,p_2,...,p_n\}, p_i \in\mathbb{R}^3$.
I want to sort $P$ so that every 4 consecutive points forms a non-coplanar tetrahedra/3D-simplex/triangular pyramid (whatever you personally call it), I know there will be left over points, so I want to do this maximally, meaning I want to create the maximum number of tetrahedra from the set of points and have them back-to-back in the array as every 4 points. And any left-over points will be at the end of the array (after the tetrahedra) where I will have the starting index stored for those leftover points.
Does anyone know how to accomplish this? (and yes the tetrahedra can be arbitrary with no constraints, meaning they are allowed to intersect, but a point can only be used for a single tetrahedra)
(I know I can find a single simplex by first finding 2 points that are at a distance of $\epsilon$ away from each other (meaning I have 2 distinct points) then find a third point that is not colinear by using the orientation test (cross product not the zero vector of 2 vectors formed from the 3 points) then finding a fourth point by using the plane normal test (now that we have 3 points that form a plane we can create a vector from the plane to a new fourth point and compare the dot product of that point with the plane normal and if it is not zero then we have a valid simplex)). (Some thoughts on where to search is to see if this maximization problem has maybe a dual known minimization problem which I don't know what would be or to figure out if the naive algorithm of just grouping 4 points at a time until you can't anymore achieve the maximum or not).