Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using this method to detect collision between two AABBs. The algorithm is simple, fast and works great. It uses the relative velocity between the two objects to calculate TOI. This works fine with Euler, but now i'm trying to switch to RK4, which makes it hard for me to determine the TOI since i can't just divide the distance between the two AABBs by their relative velocity. Since RK4 is so popular, how do people deal with this issue? How to calculate a TOI for a swept AABB with RK4?

share|improve this question
up vote 2 down vote accepted

Integration should have nothing to do with calculating the TOI. I'm not sure where your problem is as RK4 only allows for more accurate results by allowing a more accurate acceleration curve during each time step. Remember acceleration is just the change in velocity over the time step.

Thus vel = accel / dt or vel = accel * inverse_dt

The swept box algorithm you provided calculates it's own velocities inside itself based on the new and old positions. To find the position of each box at the TOI just multiply that velocity by the TOI for each box, not what RK4 has found.

I'm also assuming your only using linear motion as your swept box detection does not provide a contact point.

share|improve this answer
Decent answer. RK4 can be used where slightly improved stability and paranoid accuracy are required, but it doesn't mean that dividing the distance by the relative velocity, no matter how the values get computed, is not the way to go. It is true that the velocity is no longer linear across the delta_time interval, but the difference in results should not be a huge deal. If it is, maybe the OP can tell us what went wrong with this idea (missed collisions, penetration artefacts?) – teodron Apr 2 '13 at 6:46

Your Answer


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.