1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! 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
//! ```
use Ordering;
use Coord;
use cratePoint2;
/// The exact sign of a predicate's determinant.
/// 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.
/// 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.