Sign in to follow this  

Verlet Intergration problem

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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
void add_acc(float a)
{
acceleration=a/60;
}

pos +=(pos - prev_pos) + acceleration;

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this