I am working on a simple rigid-body physics engine ,I've already implemented SAT algorithm for collision detection and everything works fine, Now i get to step to use MTV to calculate the distance which objects might move to, In my case the two objects are cubes ,Actually i am a little confused about the distance and how to use it

Here is the two cubes

Huge Cube and Small One

Both of them are on the same y-axis and z-axis, Only differs in x-axis

I am calculating MTV and i get:

samllest which refers to the smallest axis, So it looks like (x,y,z).

overlapDistance which refers to the smallest overlap distance as a double variable.

I know that overlapDistance is the distance that one of two cubes should move till no collision

But how to use it , How cubes should respond to this distance ?

Sorry if i am not clear, but for summary i know the smallest overlap distance but i don't know how to get use of it

  • 1
    \$\begingroup\$ What is the context? Do you want to separate the two cubes if they overlap, or do you want to resolve a collision? The MTV is fine in the first case, but pretty much useless in the latter \$\endgroup\$
    – Bálint
    Jun 2, 2019 at 16:09
  • \$\begingroup\$ I want to resolve the collision so each cube goes to the right place , Any idea for this i would be thankful \$\endgroup\$
    – Falyoun
    Jun 2, 2019 at 17:26

1 Answer 1


The minimum translation vector isn't a good choice when resolving collision. For example, let's look at the following case:

enter image description here

The three parts of the image show the three states of the physics engine given a static square and a dynamic one (for simplicity). The dynamic object enters the static one during the update. The minimal translation vector is always the shortest vector, that completely separates the two objects, but it's not always the correct one. The MTV here dictates, that the shortest path to separation is to move the dynamic object vertically upwards. This shouldn't happen, since it entered the static one from the sides and everyone would expect it to stop. This leads to the dynamic object essentially jumping across the static one.

If you want to separate the squares realistically, follow this answer

If you don't care, then it's pretty simple. Just take the smallest vector, multiply it by overlapDistance and subtract it from the position of the moving square

  • \$\begingroup\$ So clear and helpful , Many thanks \$\endgroup\$
    – Falyoun
    Jun 2, 2019 at 21:12

You must log in to answer this question.

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