I am trying to implement Delaunay triangulation. Its working fine most of the time. But when the density of the points gets very large i start to get tetrahedrons where all 4 points lie on a single plane. In these cases my calculation of circumcenter breaks.
Current solution:
DoubleVector v1 = p2.loc - p1.loc;
DoubleVector v2 = p3.loc - p1.loc;
DoubleVector v3 = p4.loc - p1.loc;
double l1 = v1.sqrMagnitude;
double l2 = v2.sqrMagnitude;
double l3 = v3.sqrMagnitude;
circumceter = p1.loc + (l1 * DoubleVector.Cross(v2, v3) + l2 * DoubleVector.Cross(v3, v1) + l3 * DoubleVector.Cross(v1, v2)) / (2 * DoubleVector.Dot(v1, DoubleVector.Cross(v2, v3)));
P1, P2, P3, P4 are the vertices of the tetrahedron.
This approach can handle all the other cases except the case where all 4 points lie on the same plane.
Is there a way to find a circumcenter(if it exsists) on any tetrahedron.
The circum-sphere degenrates to the plane containg the four points. In the code you can write it in as a special trivial case when volume of (the flattest) tetrahedron is zero.