Package-level declarations
The decision tier: predicates answering Boolean where the operator tier answers geometry — incidence (on), containment (contains, spelled in/!in), and region overlap (intersects). Every answer is rounded at the SCALE quantum.
Every predicate is closed — the boundary belongs to the shape:
| State | Spelling | Decision |
|---|---|---|
| on | p on c | round(dot) == 0 |
| inside | p in cc contains p | round(dot) >= 0 |
| outside | p !in c!(c contains p) | round(dot) < 0 |
so the three states partition exactly at the quantum and on implies inside (p on c implies p in c). intersects is closed on the same terms, giving on-implies-intersects — the derived families agree with on at the boundary by construction. The strict (open) interior is deliberately unnamed — negation spells it: p !in -c holds exactly when p is strictly inside c, because both orientations are closed and only the strict interior escapes the complement.
The on family
on tests whether a point lies on a shape's boundary.
| Pairing | True when |
|---|---|
FlatPoint on LineRoundPoint on Line | the point lies on the line |
FlatPoint on CircleRoundPoint on Circle | the point lies on the circle — orientation-blind |
FlatPoint on SegmentRoundPoint on Segment | the point lies on the segment itself, endpoints included |
FlatPoint on PolygonRoundPoint on Polygon | the point lies on any edge |
Precision is not uniform across the pairings: the Line, Segment, and Polygon forms are all-linear and robust at the SCALE quantum; the Circle forms are quadratic, so the residual grows with the radius and a point near a large circle's boundary may fail the test. Callers wanting a "near" test need their own tolerance.
The contains family
contains decides containment, boundary included. It is a Kotlin operator fun, so the call-site spellings are the language's: point in circle reads inside-or-on, and point !in circle the strict outside — neither inside nor on, the boundary belonging to the shape. There are deliberately no inside/outside functions: one relation, one name, with in/!in as its syntax.
| Pairing | in is true when |
|---|---|
Circle contains FlatPointCircle contains RoundPoint | the point lies in the circle's interior or on it |
Circle contains Circle | the other circle's region lies within the receiver's |
Polygon contains FlatPointPolygon contains RoundPoint | the point lies within the polygon's solid region or on its boundary |
Every form is orientation-aware: an inside-out circle's interior is the unbounded region outside it, and an inside-out polygon — wound clockwise — contains the closed complement of its loop. The circle forms share on's quadratic precision caveat. Classic polygon containment follows the nonzero winding rule, so self-touching and self-crossing loops classify by winding; the inside-out reading is its complement, boundary included either way.
The intersects family
intersects tests region overlap — "not disjoint": two shapes intersect when they share at least one point, touching included. Polygon operands count as closed regions (interior plus boundary); segments and lines as their point sets. The predicate is symmetric, and cross-type pairings come in both operand orders.
| Pairing | True when |
|---|---|
Segment intersects LineLine intersects Segment | the line touches or crosses the segment |
Segment intersects Segment | the segments touch, cross, or overlap |
Polygon intersects LineLine intersects Polygon | the line reaches the polygon's solid region — always, when the polygon is inside-out |
Segment intersects PolygonPolygon intersects Segment | the segment touches the boundary or lies within the solid region |
Polygon intersects Polygon | the solid regions share any point — always, when both are inside-out |
A polygon operand is its oriented solid region: a classic polygon fills its loop, an inside-out one the closed complement. Two inside-out polygons always intersect — both solid regions are unbounded, and far enough out every direction belongs to both. The name is the DE-9IM sense of intersects — not DE-9IM overlaps, which would exclude containment and touching. The boolean answer is the whole product: the crossing geometry itself comes from meet.
Functions
Polygon contains FlatPoint => Boolean
Returns whether the point lies within the polygon's solid region, boundary included.
Polygon contains RoundPoint => Boolean
Returns whether the point lies within the polygon's solid region, boundary included.
Circle contains Circle => Boolean
Returns whether the other circle's region lies within the region this circle bounds, boundaries included — internal tangency and identical circles count.
Circle contains FlatPoint => Boolean
Returns whether the point lies in the circle's interior or on the circle.
Circle contains RoundPoint => Boolean
Returns whether the point lies in the circle's interior or on the circle.
Polygon intersects Polygon => Boolean
Returns whether the two solid regions share any point — touching boundaries count.
Polygon intersects Segment => Boolean
Returns whether the segment touches the polygon's boundary or lies within its solid region.
Polygon intersects Line => Boolean
Returns whether the line reaches the polygon's solid region.
Segment intersects Polygon => Boolean
Returns whether the segment touches the polygon's boundary or lies within its solid region.
Segment intersects Segment => Boolean
Returns whether the segments touch, cross, or overlap, endpoints included.
Segment intersects Line => Boolean
Returns whether the line touches or crosses the segment.
Line intersects Polygon => Boolean
Returns whether the line reaches the polygon's solid region.
Line intersects Segment => Boolean
Returns whether the line touches or crosses the segment.
FlatPoint on Polygon => Boolean
Returns whether the point lies on the polygon's boundary.
FlatPoint on Segment => Boolean
Returns whether the point lies on the segment itself, endpoints included.
FlatPoint on Circle => Boolean
Returns whether the point lies on the circle.
FlatPoint on Line => Boolean
Returns whether the point lies on the line.
RoundPoint on Polygon => Boolean
Returns whether the point lies on the polygon's boundary.
RoundPoint on Segment => Boolean
Returns whether the point lies on the segment itself, endpoints included.
RoundPoint on Circle => Boolean
Returns whether the point lies on the circle.
RoundPoint on Line => Boolean
Returns whether the point lies on the line.