Sign in to follow this  
Makers_F

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

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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this