Public Group

# [2D] Bonding Box of collision region of 2 rectangles

This topic is 2213 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello,
i'm implementing pixel perfect collision, and in order to make the check faster i want to cull the unused part of the 2 sprites colliding.
I need to find the red area in the pictures (the rectangles can be scaled, rotated, screwed), possibly the one from the last 2 pictures(where the rectangle is parallel to one of the 2 rectangles), but i'm a little confused. I have the vertices in world space, but i can't figure a way to correctly test the right intersections(for each way i think it could be done i can think of a corner case in which it is wrong).

Is there some algorithm to perform this check? I wasn't able to find one, despite the fact it should be a well studied/known subject (at least, i thought 2D collision is a well known and already deeply studied subject..)

[attachment=10240:intersection.png]
bounding box parallel to the world space axis.
[attachment=10241:intersection2.png]
[attachment=10242:intersection3.png]
bounding box parallel to the local X axis of one of the 2 rectangles
Ps: i have the transformation matrices of both the rectangles

##### Share on other sites
Hmm, I don't know if there's a better way to do it, but you could probably just clip one rectangle with the other one? You can maybe have better answers if you post this in the Math/Physics forum too.

1. 1
2. 2
frob
15
3. 3
4. 4
5. 5

• 13
• 13
• 14
• 68
• 15
• ### Forum Statistics

• Total Topics
632138
• Total Posts
3004315

×