3
\$\begingroup\$

What is the MTV (Minimum Translation Vector) in SAT (Seperation of axis)? and how can i use it?

Im trying to create my first game, where a ball can hit a a static brick (rectangle). Now if a ball collides with a brick, then i need to figure out which side the ball collided with so i can tell the ball which direction it should bounce off to.

For example, if a ball is heading nortwest and hitting the brick on its right side, then it should bounce in a northeast direction.

however if the ball hit's the bottom side of the brick, then the ball should be heading southwest.

So can the MTV be used in this situation? can MTV tell me which side of a rectangle the ball has impacted?

Please note i have implemented SAT in my game, and the collision detection works fine, my question now is, can i use MTV to actually handle a collision response?

fig1

Any help is appreciated.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Your questions have been asked before. First determine the side impacted with. Then find the resulting vector. It's a very common question, and I can't imagine that you actually searched the site first. \$\endgroup\$
    – House
    Commented Jul 18, 2012 at 14:03

1 Answer 1

7
\$\begingroup\$

The minimum translation vector is the shortest distance that the colliding object can be moved in order to no longer be colliding with the collidee.

Most of the time, this will be the normal of the face which first impacted. When this is the case, you can use this to handle collision response by (in the case of perfectly elastic collisions with an immobile brick) reflecting the velocity of the ball with respect to the normal of the MTV, and adding twice the MTV to the position of the ball.

There are cases where the minimum translation vector isn't the normal of the face impacted: planing, and when the translation of the ball is approaching the size of the brick. These may occur sufficiently rarely that you don't need special-case handling for them, depending on your timestep, velocities involved and object sizes.

edit: For example, given your diagram, you're going to get tunnelling effects if the ball ends up penetrating the brick more than halfway - at that point, it'll end up getting pushed out of the other side of the brick.

Further edit: Just realised, you can solve both planing and tunnelling by calculating the dot product of the various translation vectors with the relative velocity of the objects. Any translation vector which has a positive dot product with the velocity can't be a collision face, as the object is moving away, not towards, that face. Of those which give a negative dot product, it's the one which gives the smallest value which will be the first side impacted.

\$\endgroup\$
0

You must log in to answer this question.

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