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 circleEnums§
- Sign
- The exact sign of a predicate’s determinant.
Functions§
- incircle
- The exact position of
dagainst the circle througha,b,c, which must be counter-clockwise:Positiveinside,Negativeoutside,Zeroon the circle. For a clockwisea b cthe signs swap; for a collinear one the “circle” is the line and the result isZerofor everydon it. - orient2d
- The exact sign of twice the signed area of the triangle
a b c:Positivewhen the points turn counter-clockwise (cis left of the directed linea → b),Negativewhen clockwise,Zerowhen collinear.