I am using Rotated Rectangles which collide using the Separating Axis Theorem and they work perfectly fine for collision detection using Intersects and Contains.

However, I am starting to use faster objects in my game now and there is the issue of the two object overlapping during collision due to their higher velocities. I would like to do a collision response where I find out how much they are overlapping in the X and Y and put position them outside of each other.

I would like to use something like this: http://go.colorize.net/xna/2d_collision_response_xna/index.html.

But I am having some issues trying to adapt this to handle the rotation of the bounds.

Is this possible? Are there any resources out there that I can look at?

  • \$\begingroup\$ Try enabling continuous collision detection. \$\endgroup\$ Oct 8, 2012 at 19:36
  • 1
    \$\begingroup\$ All collision detection is handled by me. I don't have a continuous collision detection option. \$\endgroup\$ Oct 8, 2012 at 19:39
  • \$\begingroup\$ My bad I misread faster as farseer as in the physics engine. \$\endgroup\$ Oct 8, 2012 at 19:42

2 Answers 2


I found a version of the Separating Axis theorem that includes the creation of a minimum translation vector (MTV), the use of this vector allows me to place the objects that are colliding outside of the collision and generate physics properties based on the collision.



The simple, but resource consuming solution is to calculate multiple states in a single update. Normally we calculate the positions of the object 'A' once every update. So in 3 consecutive updates, we're gonna calculate P_A, P_A' and P_A''. This is fine for most game engines, but as velocities get higher, and / or objects get smaller, the difference between P_A and P_A' may be too big to notice a collision that actually occurs between the two.

However, nobody says that we have to calculate exactly once the new position of 'A' in each update. You get the elapsed game time, and use fractions of it to calculate multiple position between P_A and P_A': P_A1, P_A2, P_A3 etc. Then you do it for the other object ('B') as well: P_B1, P_B2, P_B3 etc. Once you calculated P_A1 and P_B1, you do a collision detection with those positions. If there's no collision, you do it with P_A2 and P_B2, and so on.

Yes, this can slow down your game if you have lots of objects. If you run into performance issues, then you might have to dig deep into mathematics, I'm afraid. I'm actually representing rotated rectangles as polygons in my engine. You might want to look into Polygon collision detection, and the point-in-polygon algorithm. Maybe you can find some useful ideas.

  • \$\begingroup\$ So, you are proposing that instead of calculating intersection depth, that I instead, calculate multiple states. This is what I am currently trying to get away from. I need the intersection depth to calculate the collision response and also for calculating a deflection velocity. \$\endgroup\$ Oct 10, 2012 at 1:53
  • \$\begingroup\$ @KyleUithoven Well, as I said, it's "the simple, but resource consuming solution". It works and it does what you'd expect. I'm sure there are better solutions, but it's still better than nothing :-) \$\endgroup\$
    – Marton
    Oct 10, 2012 at 6:16
  • \$\begingroup\$ I don't think you understand what I am saying. I already do this solution, it does not provide an intersection depth, and does not do what I am asking for in the question. \$\endgroup\$ Oct 10, 2012 at 18:53
  • \$\begingroup\$ @KyleUithoven Okay, I just assumed this was your problem.("However, I am starting to use faster objects in my game now and there is the issue of the two object overlapping during collision due to their higher velocities.") \$\endgroup\$
    – Marton
    Oct 11, 2012 at 5:38
  • \$\begingroup\$ That is my problem, which is why I am looking to get the intersection depth. If I can get the intersection depth I can get a minimum translation vector and use that to place them outside of each other and create a velocity vector based on the collision. \$\endgroup\$ Oct 11, 2012 at 21:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .