@vaguevoid/fiasco / toyPhysics / isCollidingSat
Function: isCollidingSat()
isCollidingSat(
a
,b
):boolean
Defined in: src/toyPhysics.ts:54
Uses the Separating Axis Theorem to determine if two convex polygons are colliding.
We most often use it to check collision between two rectangles that have been rotated.
If checking for collision between two rectangles that have not been rotated, you can use isBoxColliding
instead.
This is a narrow phase collision detection that works for convex polygons with any number of vertices. Note that the vertices must be in clockwise order. A vertex is defined as the point where two edges meet in a polygon.
Parameters
a
Vec2
[]
all vertices of convex polygon a. for a thing, this would be thing.bounds
b
Vec2
[]
all vertices of convex polygon b. for a thing, this would be thing.bounds
Returns
boolean
true if the polygons are colliding, false otherwise