# Verlet Intergration problem

This topic is 2181 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

What exactly is a timestep? let say i set the value of my acceleration to 2, i will expect the velocity of the my object (current position - previous position) to increase by 2 every second. Now if I run this code in 60fps, shouldn't my timestep be 1/60? However, after running it for 1 second(60 frames) i check the final velocity of the object, it's 0.032959. Am I thinking in the wrong direction?

##### Share on other sites
i think you are adding force(acceleration) or backuping position in wrong place
must be:
tmp=pos-bpos;
bpos=pos
pos+=tmp+acceleration; Edited by serumas

##### Share on other sites
so after playing around for a bit, it fixed the problem. The original formula i used that pos +(pos - prev_pos) + acceleration * timestep* timestep. I knew the problem is because of the timestep^2 in the end, so I removed 1 timestep at the end of the formula and it works just fine. But then I don't know if what i am doing is right or not. Since all the article I found about verlet integration used the formula above.

##### Share on other sites
i think best way is not to use time step.Lock your verlet update rate to constant 60 and
every timne you ad acceleration of force you just * 1/60
{
acceleration=a/60;
}

pos +=(pos - prev_pos) + acceleration;

##### Share on other sites
I am starting to think the original formula is correct. equation for calculating the displace is x = x0 + vi0*t + .5*a*t^2, i set x0 and vi0 = 0, then x = .5*a*t^2. since my a = 2, and t = 1, then x(displacement) should be 1 also. and if i used that formula i found from other article, and apply timestep of 1/60. after 1 second, the outcome is 1.00525(round off error i guess). It is close enough to the actually answer. but I still don't know why the velocity isn't 2 after one second. Physics is never my strong subject. At least i know it works correctly now. Maybe someone can explain? Thanks

1. 1
Rutin
24
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 13
• 38
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631714
• Total Posts
3001861
×