Determines whether two axis-aligned rectangles intersect.
The rectangles are defined by their top-left position (Vector) and their dimensions (Size). This function performs an axis-aligned bounding box (AABB) collision check.
Vector
Size
Top-left position of rectangle A.
Dimensions (width and height) of rectangle A.
Top-left position of rectangle B.
Dimensions (width and height) of rectangle B.
true if the rectangles overlap, otherwise false.
true
false
const collision = intersects( { x: 10, y: 10 }, { width: 50, height: 50 }, { x: 40, y: 40 }, { width: 30, height: 30 }); Copy
const collision = intersects( { x: 10, y: 10 }, { width: 50, height: 50 }, { x: 40, y: 40 }, { width: 30, height: 30 });
Determines whether two axis-aligned rectangles intersect.
The rectangles are defined by their top-left position (
Vector) and their dimensions (Size). This function performs an axis-aligned bounding box (AABB) collision check.