Skip to main content

Module intersection

Module intersection 

Source
Expand description

Collision and intersection: point-in-polygon, segment-polygon, circle-polygon, polygon-polygon (SAT), convex hull, convexity test.

Functions§

circle_intersects_polygon
Whether a circle intersects a polygon (edge or interior).
convex_hull
Andrew’s monotone chain convex hull algorithm.
is_convex
Whether a simple polygon is convex.
point_in_polygon
Ray-casting algorithm: does a horizontal ray from p cross the polygon edge an odd number of times?
polygons_intersect
Separating Axis Theorem: do two convex polygons overlap? Panics if either polygon is concave (SAT is only valid for convex polygons).
segment_intersects_polygon
Whether a line segment intersects a polygon.
segments_intersect
Whether two line segments intersect (proper or improper).
winding_number
Winding number algorithm: returns winding number of polygon around p. 0 = outside, nonzero = inside (with winding semantics).