Expand description
Fundamental integer geometry primitives. All coordinates are i64 (fixed-point). All intermediate computations use i128. ZERO floating point. ZERO epsilon. Exact integer arithmetic throughout.
Enums§
- Orientation
- Orientation of three points.
Functions§
- cross2d
- 2D cross product of vectors (A→B) × (A→C). Equivalent to: (bx-ax)(cy-ay) - (by-ay)(cx-ax) Positive = CCW (left turn), Negative = CW (right turn), Zero = collinear. Casts to i128 before multiply — no overflow for coords up to MAX_WORLD=40_075_017_000_000.
- edge_
squared_ length - Squared Euclidean distance between two points (using i128 to avoid overflow). Returns dx² + dy². Used for edge length validation (compare against MIN_EDGE_LENGTH_SQUARED).
- is_
collinear_ pts - True if P is collinear with A and B (cross product == 0).
- is_left
- True if P is strictly left of line A→B (cross product > 0 for CCW polygon).
- is_
left_ or_ on - True if P is strictly left of or on line A→B.
- is_
reflex - True if vertex
curris a reflex vertex in a CCW polygon. A reflex vertex has a CW turn (cross product < 0) in a CCW polygon. prev → curr → next should be a left turn for convex, right turn for reflex. - is_
right - True if P is strictly right of line A→B.
- is_
right_ or_ on - True if P is strictly right of or on line A→B.
- orientation
- Orientation of three points A, B, C.
- point_
on_ segment - True if point P lies on segment A→B (collinear AND within the bounding box of A→B).
- segments_
intersect - True if segments A1→A2 and B1→B2 intersect (proper crossing OR endpoint on segment).
- segments_
properly_ intersect - True if segments A1→A2 and B1→B2 properly intersect (cross each other, not collinear). Proper intersection: each segment straddles the other’s line (both endpoints on opposite sides). Does NOT count T-junctions (endpoint on segment) as proper intersection.