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:

StateSpellingDecision
onp on cround(dot) == 0
insidep in c
c contains p
round(dot) >= 0
outsidep !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.

PairingTrue when
FlatPoint on Line
RoundPoint on Line
the point lies on the line
FlatPoint on Circle
RoundPoint on Circle
the point lies on the circle — orientation-blind
FlatPoint on Segment
RoundPoint on Segment
the point lies on the segment itself, endpoints included
FlatPoint on Polygon
RoundPoint 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.

Pairingin is true when
Circle contains FlatPoint
Circle contains RoundPoint
the point lies in the circle's interior or on it
Circle contains Circlethe other circle's region lies within the receiver's
Polygon contains FlatPoint
Polygon 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.

PairingTrue when
Segment intersects Line
Line intersects Segment
the line touches or crosses the segment
Segment intersects Segmentthe segments touch, cross, or overlap
Polygon intersects Line
Line intersects Polygon
the line reaches the polygon's solid region — always, when the polygon is inside-out
Segment intersects Polygon
Polygon intersects Segment
the segment touches the boundary or lies within the solid region
Polygon intersects Polygonthe 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

Link copied to clipboard
infix operator fun Polygon.contains(point: FlatPoint): Boolean

Polygon contains FlatPoint => Boolean
Returns whether the point lies within the polygon's solid region, boundary included.

infix operator fun Polygon.contains(point: RoundPoint): Boolean

Polygon contains RoundPoint => Boolean
Returns whether the point lies within the polygon's solid region, boundary included.

infix operator fun Circle.contains(other: Circle): Boolean

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.

infix operator fun Circle.contains(point: FlatPoint): Boolean

Circle contains FlatPoint => Boolean
Returns whether the point lies in the circle's interior or on the circle.

infix operator fun Circle.contains(point: RoundPoint): Boolean

Circle contains RoundPoint => Boolean
Returns whether the point lies in the circle's interior or on the circle.

Link copied to clipboard
infix fun Polygon.intersects(other: Polygon): Boolean

Polygon intersects Polygon => Boolean
Returns whether the two solid regions share any point — touching boundaries count.

infix fun Polygon.intersects(segment: Segment): Boolean

Polygon intersects Segment => Boolean
Returns whether the segment touches the polygon's boundary or lies within its solid region.

infix fun Polygon.intersects(line: Line): Boolean

Polygon intersects Line => Boolean
Returns whether the line reaches the polygon's solid region.

infix fun Segment.intersects(polygon: Polygon): Boolean

Segment intersects Polygon => Boolean
Returns whether the segment touches the polygon's boundary or lies within its solid region.

infix fun Segment.intersects(other: Segment): Boolean

Segment intersects Segment => Boolean
Returns whether the segments touch, cross, or overlap, endpoints included.

infix fun Segment.intersects(line: Line): Boolean

Segment intersects Line => Boolean
Returns whether the line touches or crosses the segment.

infix fun Line.intersects(polygon: Polygon): Boolean

Line intersects Polygon => Boolean
Returns whether the line reaches the polygon's solid region.

infix fun Line.intersects(segment: Segment): Boolean

Line intersects Segment => Boolean
Returns whether the line touches or crosses the segment.

Link copied to clipboard
infix fun FlatPoint.on(polygon: Polygon): Boolean

FlatPoint on Polygon => Boolean
Returns whether the point lies on the polygon's boundary.

infix fun FlatPoint.on(segment: Segment): Boolean

FlatPoint on Segment => Boolean
Returns whether the point lies on the segment itself, endpoints included.

infix fun FlatPoint.on(circle: Circle): Boolean

FlatPoint on Circle => Boolean
Returns whether the point lies on the circle.

infix fun FlatPoint.on(line: Line): Boolean

FlatPoint on Line => Boolean
Returns whether the point lies on the line.

infix fun RoundPoint.on(polygon: Polygon): Boolean

RoundPoint on Polygon => Boolean
Returns whether the point lies on the polygon's boundary.

infix fun RoundPoint.on(segment: Segment): Boolean

RoundPoint on Segment => Boolean
Returns whether the point lies on the segment itself, endpoints included.

infix fun RoundPoint.on(circle: Circle): Boolean

RoundPoint on Circle => Boolean
Returns whether the point lies on the circle.

infix fun RoundPoint.on(line: Line): Boolean

RoundPoint on Line => Boolean
Returns whether the point lies on the line.