Suppose there are two quadrilaterals A and B. A is stationary but B is moving. They collided. Now B is inside A.

To check if they are intersecting I can use 2d separating axis theorem (SAT). To push B out of A so that they are not intersecting anymore, I can again use SAT to get the Minimum Translation Vector(MTV) and project B out of A using it.

My problem is, what should I do when both A and B were moving, and then they collided? I can't project A out of B or B out of A alone since both of them were moving. How should I separate them?


If you seperate along the Minimum Translation Vector, you could be getting some very jerky behaviour.

I think you should do your projection backwards along the movement path, which lead to the collision.


Then you can resolve your collision physics (change of movement direction ...) and move the object that collided the rest of it's new movement for the partial timestep still missing.

If you do that, then 2 moving objects is straightforward:

You subtract their velocity vectors and calculate how far you would have to move the first of the two backwards along this combined velocity to avoid the collision. Then you calculate the timelength that represents and actually move both of them backwards along their orginal velocities.

edit for clarity:

For two moving object if the first moves with a velocity of v1 and the second with v2, then resolve the collision hypothetically with a velocity of v=v1-v2 (vector valued) for the first object and 0 for the second objects velocity. You get a negative timestep dt, which you would have to move the first obeject backwards. Multiply this timestep with the actual velocities, v1 and v2, to move both object backwards.

  • \$\begingroup\$ I already know that process. Infact I use that. But I asked, how to correctly separate them when both were moving with different velocities. \$\endgroup\$ – arandomguy Aug 27 '16 at 6:19
  • \$\begingroup\$ Well, maybe I should have made the two object description (the second part) clearer. Will do that in a edit. Your description sounded like you seperate along the MTV direction not along the velocity. \$\endgroup\$ – mmmd Aug 27 '16 at 23:32

Not completely sure if this answer is 100% correct, but i can't comment yet :/

First a question, is it completely necesary to have objects get inside another object and then pushing it out?

What i mean is, maybe you can avoid movement in a certain direction in case there is "going to be" a collision.

im not sure how modern engines handle collisions, but what if when you detect a collision you instance a collision handler, who knows both colliders and can correct the positionning of both?

  • 2
    \$\begingroup\$ instead of just giving a -1, a comment on reasoning would be nice \$\endgroup\$ – Brian H. Aug 25 '16 at 11:30
  • \$\begingroup\$ You say check collision before it actually happens ? \$\endgroup\$ – arandomguy Aug 25 '16 at 11:49
  • \$\begingroup\$ no, check collision before actually moving the object, you can calculate it's position without needing to set it there yet edit: ok im starting to see the flaws... i'll remove the answer \$\endgroup\$ – Brian H. Aug 25 '16 at 12:00
  • \$\begingroup\$ Yes, collision determination can occur prior to an actual collision, Raj. It's not unheard of to use a deterministic approach to exactly this sort of thing. \$\endgroup\$ – Jesse Williams Aug 25 '16 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.