gap

infix fun Polygon.gap(other: Polygon): Segment?

Polygon gap Polygon => Segment?
Returns the shortest segment from this polygon to other — from a point of one boundary to the nearest point of the other's — or null when their solid regions share any point, touching included.

The closest pair of the two boundaries as a Segment whose Segment.start lies on this polygon and Segment.end on other; its length is the shortest distance between them, raw at full Double precision. Existence is the closed region overlap Polygon intersects Polygon, rounded at the SCALE quantum: two polygons whose solid regions overlap or touch have no gap — whether a vertex of one rests on a face of the other or a face on a vertex — and a shortest distance that rounds to zero at the quantum answers null all the same. Each operand is its oriented solid region: a classic polygon fills its loop, an inside-out one (Polygon.isInsideOut) the closed complement, so a polygon within an inside-out one pairs to the loop from inside, and two inside-out polygons never have a gap. No convexity is required of either operand. When several pairs share the shortest distance — parallel faces — one is picked arbitrarily; the displacement from Segment.start to Segment.end is the same for all of them.

Receiver

The polygon the segment starts on.

Return

The raw shortest Segment from this polygon to other, or null when the solid regions share at least one point.

Parameters

other

The polygon the segment ends on.