collidex v0.1.0 Collidex.Detection.Polygons

Detects collisions between polygons using the separating axis theorem. Has two variants, :fast and :accurate. :fast will miss a few rare tyes of collisions but is much faster.

Summary

Functions

Determine if two polygons are colliding. Uses the separating Axis Theorem, and so can only perform accurate detection for convex polygons

Functions

collision?(poly1, poly2, type \\ :accurate)

Determine if two polygons are colliding. Uses the separating Axis Theorem, and so can only perform accurate detection for convex polygons.

if :fast is passed as the third argument, this function will use the shortcut method of only checking one axis: the centroid-to-centroid axis. This method is faster (at least as fast, with much better worst-case performance) and will correctly detect the vast majority of collisions, but will occasionally return a false positive for almost-colliding acute polygons (particularly triangles) at skew angles.