Time Corrected Verlet Integration and too big timesteps
Asked Answered
C

2

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?

Costive answered 13/4, 2012 at 11:6 Comment(0)
S
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.

Shotwell answered 13/4, 2012 at 12:16 Comment(2)
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?Costive
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 DuyCostive
M
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.sstatic.net/TL6HT.png

Mellen answered 21/1, 2015 at 7:4 Comment(4)
Can you clarify what the variables represent?Sloane
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.Mellen
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.Mellen
Look what I just found, a third party confirmation! Well sort of, it confirms by application, not derivation. #32710099Mellen
S
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.

Shotwell answered 13/4, 2012 at 12:16 Comment(2)
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?Costive
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 DuyCostive

© 2022 - 2024 — McMap. All rights reserved.