2
\$\begingroup\$

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

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – dmckee
    Nov 11, 2012 at 0:32

1 Answer 1

3
\$\begingroup\$

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.

\$\endgroup\$
0

You must log in to answer this question.

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