#### Archived

This topic is now archived and is closed to further replies.

# verlet integration

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

## Recommended Posts

I''m a little confused on euler vs verlet integration;
// euler

foreach step {
velocity += some stuff;
position += velocity;
}

// verlet?

foreach step {
velocity += some stuff;
position += velocity;

velocity = o - position
o = position; // save position

}

As far as I can tell, this gives the EXACT same results, UNLESS you start explicitly start meddling with the position... Is any of this thinking correct?

##### Share on other sites
there is no velocity in verlet, generally:

position = 2 * position - oldposition + acceleration * dt * dt;

and yes, you''re right, it gives the exact same results unless you fiddle with the position. It makes completely non-bouncy physics (balls that splat into a wall and fall down, or cloth simulations with rigid springs) much simpler. It makes more sophisticated physics more awkward. I use it for cloths and I was amazed how little time it took to implement for the first time (3 or 4 hours and I had cloth floating down over a sphere).

##### Share on other sites
AFAIK with Verlet the velocity is estimated from the position change, that''s why you must save it. And the new position is directly calculated from acceleration.
Have you checked this out:
http://www.ioi.dk/Homepages/thomasj/publications/gdc2001.htm

##### Share on other sites
Ok, seems i got it right then :-) I was just suprised the two methods were just different ways of juggling the figures to the same result; but when collisions come into play (with direct positional changes) they will produce different results...

##### Share on other sites
fenghus,

Actually, your Euler (note capital letter ''E''---since Euler is a person''s name) is not in fact Euler. Well it is, but its two kinds of Euler. Your velocity update is explicit or simple Euler (the bad kind). But your position is implicit Euler (the good kind). The difference is that the bad kind of Euler updates the left hand side using a right hand side that was calculated based on data from the previous time step, while the good kind of Euler updates the left hand side using a right hand side that is for the current time step. Since your veloocity used in your position update is for the new time step, you have basically used implicit Euler for position. So, as a whole you''ve used a semi-implicit integration that is more stable than the fully explicit method that we usually are talking about when we refer to "Euler" integration. All by sheer accident, I''m guessing!

If you flipped your order and updated position first, then velocity, you''d have a fully explicit Euler, bad idea.

All this really depends, though, on what exactly you have in your "some stuff" bits, .

Graham Rhodes
Principal Scientist
Applied Research Associates, Inc.

##### Share on other sites
Oi! Yeah, i'm just googling and browsing my way thru stuff and coding what I think sounds most logical (and manage to understand) :-)

Some stuff bits looks something like this (pseudocode):

cmforce += spring forcescmforce += gravity * massvelocity += cmforce / masscmforce = 0

... all modified by timestep of course. Btw, I guess gravity could just be added to velocity, but this way looks more understandable - i'll optimize later :-)

[edited by - fenghus on May 28, 2004 3:52:18 AM]

##### Share on other sites
This message is for Squirm. I am using Verlet to simulate cloth. I have some implementation questions for you about cloth in general. How do you recommend handling the folding of cloth? I ask this because I have linear spring interactions where a radius of interaction determines which nodes are a given node''s neighbor. The problem is if two nodes that aren''t neighbors are close there is nothing to repel them in the force calculations.
Any suggestions?
Thanks

##### Share on other sites
So, if your cloth folds over it passes through itself...? A search term for google would be "self intersecting cloth", though I haven''t looked myself yet.
I do have that problem. Mostly it isn''t bothering me since I have avoided situations that cause it. Another thing I have is an alternative constraint. This isn''t something I''ve picked up off the net - it is just the solution that occurred to me:

Normally, your constraint would attempt to fix the distance between two nodes in the cloth. By adding constraints which only fix the distance if it is less than the minimum you effectively get a sphere around each node into which others can''t pass.

CalculateDistance();
FixDistance();
do:
CalculateDistance();
if(DistanceLessThanMinimum)
FixDistance();

You can also do cloth-sphere collision detection/response using this, which is nice and easy if the thing wearing the cloth looks like a bunch of spheres

To be perfect, that system would require every single node to have such a constraint to every other node, which would be expensive. It also requires a whole heap of if statements. In my case, only those just beyond the range of the normal spring constraints have them, and it seems to be working with only the occasionaly snag.

There is probably a more efficient solution from the realm of collision detection in general - I went for keeping it simple unless it turns out to be a bottleneck.

• 10
• 19
• 14
• 19
• 15