nimby install bumpy
Based on the book http://www.jeffreythompson.org/collision-detection/table_of_contents.php
Mostly used for vector 2d intersections checking for Pixie: https://github.com/treeform/pixie
Supported intersections:
| Shape | Point | Circle | Rectangle | Segment | Polygon | Line | Wedge |
|---|---|---|---|---|---|---|---|
| Point | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Circle | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Rectangle | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Segment | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Polygon | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Line | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Wedge | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
All shapes support overlaps.
if overlaps(circle, point):
echo "Circle and point overlap"if contains(circle, point):
echo "Circle contains point"And some shapes support intersects functions.
var at: Vec2
if intersects(circle, segment, at):
echo "Circle and segment intersect at ", atvar at: Vec2
if intersects(circle, polygon, at):
echo "Circle and polygon intersect at ", at