Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just implemented collision detection using SAT and this article as reference to my implementation. The detection is working as expected but I need to know where both rectangles are colliding.

I need the center of the intersection More examples

I need to find the center of the intersection, the black point on the image above. I've found some articles about this but they all involve avoiding the overlap or some kind of velocity, I don't need this.

I just need to put a image on top of it. Like two cars crashed so I put an image on top of the collision. Any ideas?

## Update

The information I've about the rectangles are the four points that represents them, the upper right, upper left, lower right and lower left coordinates. I'm trying to find an algorithm that can give me the intersection of these points.

share|improve this question
Why can't you just take the midpoint of the two rectangles' centers? – you786 Oct 2 '12 at 18:18
Would this work with rotated rectangles? I've updated the question with more examples – Felipe Cypriano Oct 2 '12 at 18:26

You dont actually want the center of collision, generally. The term to look for is "polygon clipping." I'll try to give a quick description.

The idea is to clip one polygon's edges against the incident edge (the axis you separated on), as well as the edge's ends. The clip points you end up with (usually two) will be the contact points to use for physics. You can join these with any interior vertices in the collision if you need a shape rather than just points, by you generally don't need that.

share|improve this answer
polygon clipping would be the same as finding the intersection area ? – Felipe Cypriano Oct 2 '12 at 19:24
It's a subset of it, basically. For game physics, you generally just want those contact points, not the whole area, so you can simplify and avoid calculating the whole area. – Sean Middleditch Oct 2 '12 at 20:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.