Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Here is my problem.

I'm working on the physics for my 2D game.

All objects are oriented bounding boxes (OBB) based on the separate axis theorem.

In order to do collision resolution, I need to be able to get an object out out of the object it is penetrating.

To do this I need to find the normal of the face(s) that the other OBB is touching.

Example: enter image description here

The small red OBB is a car lets say, and the big OBB is a static building. I need to determine the unit vector that is the normal of the building edge(s) the car is penetrating to get the car out of there.

Here are my questions:

  1. How do I determine which edges the car is penetrating.

  2. I know how to determine the normal of an edge, but how do I know if I need (-dy, dx) or (dy, -dx)?

  3. In the case I'm demonstrating the car is penetrating 2 edges, which edge(s) do I use to get it out?

Answers or help with any or all of these is greatly appreciated.

Thank you

share|improve this question

migrated from physics.stackexchange.com Nov 11 '12 at 4:27

This question came from our site for active researchers, academics and students of physics.

1  
This is clearly a problem in programing (and game programing in particular). I mean, seriously, your title mentions a programming construct (a bounding box) and does not mention a physics concept. I'll contact the mods at GameDev.SE to see if they want it. –  dmckee Nov 11 '12 at 0:32

1 Answer 1

up vote 2 down vote accepted

I think what you need is the Minimum Translation Vector (MTV). This is the smallest displacement which will separate the intersecting two objects.

The MTV is easy to find when using SAT.

  1. Find the normal (separtaing axis) with the smallest overlap
  2. The direction of the MTV is the direction of this axis
  3. The length of the MTV is the amount of overlap

The direction of the MTV will depend on which objects's normal was used. E.G. If the normal belonged to the car, then the MTV will be pointing away from the car.

share|improve this answer
    
Thank you for this great explanation! –  Milo Nov 11 '12 at 14:09

Your Answer

 
discard

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.