pub fn in_diametral_sphere(
a: Point3,
b: Point3,
c: Point3,
d: Point3,
) -> CertifiedExpand description
Is d inside the diametral sphere of the triangle a, b, c?
The diametral sphere is the smallest sphere through a, b, c: its
centre is the triangle’s circumcentre and its equator the circumcircle.
For d coplanar with the triangle this is therefore the coplanar
incircle test in 3D – the question a 3D Delaunay triangulation asks of
a point lying exactly in the plane of a convex-hull face – and, unlike
insphere, it needs no orientation: Sign::Positive means strictly
inside, Sign::Negative strictly outside, Sign::Zero on the sphere.
The sign is that of
-( |n|^2 (w.w) - |u|^2 ((w x v).n) - |v|^2 ((u x w).n) )with u = b - a, v = c - a, w = d - a and n = u x v: |n|^2 times
the power of d with respect to the sphere, a degree-6 polynomial in the
coordinates.
A degenerate triangle (collinear a, b, c) has no diametral sphere and
returns Zero. A forward running-error filter decides almost every case;
the exact expansion path decides the rest. The exact path needs every
non-zero coordinate magnitude in [2^-100, 2^100], so that no product in
the degree-6 determinant leaves binary64’s normal range; outside it, and
for non-finite input, the result is Certified::Uncertain rather than a
guess.