5

i use a Time Corrected Verlet Integration found here: http://www.gamedev.net/page/resources/_/technical/math-and-physics/a-simple-time-corrected-verlet-integration-method-r2200

But when my ball is on a wall (horizontal wall, ball upon it and the acceleration is directed down) for a some time, my game cannot recognize the collision in the right way and the ball goes down. If I put a fixed cap to deltatime like 1/60 it seems to work.

I think the problem are too big timesteps. But the time corrected verlet integration is done to avoid too big timesteps, it is right? If yes, why I need the time cap?

Bart
  • 19,692
  • 7
  • 68
  • 77
thebestneo
  • 137
  • 1
  • 6

2 Answers2

7

The equation given in the article is broken, erroneous. When I derive it, I get this:

x = x + (x – xl)*h/hl + a*h*(h + hl)/2

instead of his, which is this:

x = x + (x – xl)*h/hl + a*h^2

and here's an example using his charts: https://i.stack.imgur.com/TL6HT.png

Aru
  • 111
  • 1
  • 5
  • Can you clarify what the variables represent? – RenaissanceProgrammer Feb 25 '16 at 00:16
  • 2
    h is the timestep duration (delta time), hl is the previous timestep (the previous delta time.. l for 'last'), x and xl are the positions, a is acceleration. Also, I was kind of in programmer mentality, so it's not really an 'equation', more like an assignment operation, where the value of x is reassigned. I haven't looked at this in so long, so I can't point out the exact logical error in the article, but it's there somewhere, because as the linked image shows, the article either misapplies or misderives every integration method it demonstrates. I just showed how to correctly use Verlet. – Aru Mar 06 '16 at 02:47
  • 1
    if I recall correctly, I sent an email to the site hosting the article a long time ago about how horribly misleading and wrong it is, but it looks like they never corrected or removed it, what a shame. I hope it doesn't frustrate too many people, turning them away from the subject and delaying their learning. – Aru Mar 06 '16 at 02:51
  • 3
    Look what I just found, a third party confirmation! Well sort of, it confirms by application, not derivation. http://stackoverflow.com/questions/32709599/the-time-corrected-verlet-numerical-integration-fomula?lq=1 – Aru Mar 06 '16 at 03:33
2

From what I understand, the time-corrected verlet integration only helps when you have a fluctuating framerate, but it won't help if your base framerate is too low.

Lâm Tran Duy
  • 804
  • 4
  • 8
  • I don't know if my framerate is too low, but I use a thread and every cycle I do the verlet integration. The deltatime between 2 cycles of thread is not fixed, then is fluctuating. It could be that sometimes the framerate is too low. If so, it is correct to use the cap? – thebestneo Apr 13 '12 at 14:07
  • I added a function that controls when the ball change cell. When a ball change cell from 1 to 2, for example, the function check if the last cell have a wall. If it is true, the ball is moved to last cell and its positions and lastpositions are set equal (collision to a wall -> velocity = 0). But sometimes, if i don't have the limit of deltatime, it does not work. @Lâm Tran Duy – thebestneo Apr 14 '12 at 19:22