Skip to main content

Module predicates

Module predicates 

Source
Expand description

Exact 2D orientation and in-circle predicates over robust.

These decide combinatorial questions — which side of a segment a point lies on, whether four points are cocircular — exactly on the stored coordinates, with no tolerance: a predicate is never softened by a tolerance and a tolerance comparison never pretends to be exact (docs/DATA-MODEL.md §Tolerances). The arithmetic is Shewchuk’s adaptive-precision scheme as implemented by the robust crate.

use arris_math::Point2;
use arris_math::predicates::{Sign, incircle, orient2d};

let a = Point2::new(0.0, 0.0);
let b = Point2::new(1.0, 0.0);
let c = Point2::new(0.0, 1.0);
assert_eq!(orient2d(a, b, c), Sign::Positive); // counter-clockwise
assert_eq!(orient2d(a, b, Point2::new(2.0, 0.0)), Sign::Zero); // collinear
assert_eq!(incircle(a, b, c, Point2::new(0.25, 0.25)), Sign::Positive); // inside
assert_eq!(incircle(a, b, c, Point2::new(1.0, 1.0)), Sign::Zero); // on the circle

Enums§

Sign
The exact sign of a predicate’s determinant.

Functions§

incircle
The exact position of d against the circle through a, b, c, which must be counter-clockwise: Positive inside, Negative outside, Zero on the circle. For a clockwise a b c the signs swap; for a collinear one the “circle” is the line and the result is Zero for every d on it.
orient2d
The exact sign of twice the signed area of the triangle a b c: Positive when the points turn counter-clockwise (c is left of the directed line a → b), Negative when clockwise, Zero when collinear.