interpolate::scatter::predicates
Robust geometric predicates after Shewchuk, "Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates" (1997): a floating-point evaluation with a forward error bound, and when the bound does not settle the sign, the exact value as a nonoverlapping expansion (two_sum / two_product, Dekker splitting, no FMA), whose last component carries the sign.
Functions
orient2dSource
pub fn orient2d(ax: f64, ay: f64, bx: f64, by: f64, cx: f64, cy: f64) -> f64 Twice the signed area of the triangle a b c: positive when the
points turn counterclockwise, negative clockwise, zero exactly when
they are collinear. The sign is always right; the magnitude is the
float estimate.
use interpolate::scatter::orient2d;
assert(orient2d(0.0, 0.0, 1.0, 0.0, 0.0, 1.0) > 0.0);
// Collinear to the last bit: a float formula would often say otherwise.
assert(orient2d(0.5, 0.5, 12.0, 12.0, 24.0, 24.0) == 0.0);
incircleSource
pub fn incircle(ax: f64, ay: f64, bx: f64, by: f64, cx: f64, cy: f64, dx: f64, dy: f64) -> f64 Positive when d lies inside the circle through a b c (taken
counterclockwise; the sign flips for a clockwise triangle), negative
outside, zero exactly when the four points are cocircular.
use interpolate::scatter::incircle;
assert(incircle(0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.2, 0.2) > 0.0);
assert(incircle(0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0) == 0.0); // the square's corner