Skip to main content

Module polygon

Module polygon 

Source
Expand description

A closed polygon in a plane, its corners in order and the last joined back to the first: the area it encloses and whether it holds a point. One implementation over plain coordinates, in single or double precision.

Functionsยง

contains
Whether p lies inside polygons taken together, by the even-odd rule: a point inside an odd number of them is in, so a polygon inside another is a hole whichever way either is walked.
signed_area
The area polygon encloses, signed by the way it is walked: positive counter-clockwise (x toward y), negative clockwise; zero with fewer than three corners. A caller wanting the size alone takes abs.