Skip to main content
gamedev.net
🔒 Locked

Verlet Implementation

Started by andy_s_1 Jan 17, 2007 at 9:33 AM 2 replies 900+ views
Original Post
andy_s_1
andy_s_1
I am currently working on a cloth simulation projects where i have a mass spring system set up and i currently have RK4 as my integration method, i am trying to set up Verlet so that i can compare them for my project. but I'm having a bit of difficulty! I am in the understanding that i need to use the velocity verlet method, here is the maths i am using: x(t+h) = x(t) + v(t)h + (1/2)a(t)h^2 t = current time h = timestep (dt) x = position v = velocity a = (1/mass)force //the force is produced from my spring system, RK4 works fine form this force = (0,-9.8,0) //gravity for each spring connected force -= (SpringTension*direction) but its the velocity that is messing me up! how do i find v(t)? reading the Time corrected verlet method posted on this site, I'm having trouble implementing that as well x(t+h) = x(t) + (x(t) - x(t-h)) + ah^2 its the (x(t)-x(t-h)) part, am i supposed to store the current position and the previous position for each point? the subtract one from the other to give me the difference? but where does velocity come into that? I'll go sit in the corner with my confused cap on for a while :) Thanks for looking!
Xetick
Xetick
Yes your on the right track.
x(t+h) is the points position in the future
x(t) is the points current position
x(t-h) is then the points old position

The verlet integrator doesn't use velocity. That's what makes it so stable. Instead for each point you have the current pos and the points old position. The 'velocity' is the difference between the two. So if you want your point to move in a direct you just apply a negative velocity to the points old position.

You can NOT calculate the old position from any velocity you have. You need to store it to make it stable.

I implemented just such a system many years ago on the old Xbox and it works very well and is extremely fast. Had enough time to run a few rippable cloths and the rest of the game world with ease even on the old xbox. Ahh.. those where the days =)
Plane9 - Home of the free scene based music visualizer and screensaver
andy_s_1
andy_s_1
Thanks for your reply, i had it working without using the velocity but it was bouncing erratically which i put it down to the spring system. reading Jakobsen's Advanced Character Physics on gamasutra i came across and implemented the "Solving several concurrent constraints by relaxation" which pulls the points closer together when working out the force with springs making them the rest length of the spring.

it seems pretty stable, i shall test it against collisions with a sphere now!

cheers for your help :)
Rockoon1
Rockoon1
verlet + relaxation is more than just stable, its some sort of uber hyper-stable. Its damn near (if not entirely) impossible to make it unstable if the constraints are rational.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.