Sign in to follow this  

Verlet Integration (Olii?)

This topic is 4756 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

Hello, I've been working on getting a simple physics sim up and running using the verlet integration scheme, but Im having a bit of a problem. Objects seem to want to "blow up", especially squares, but triangles seem to work ok. It seems if any force is applied to any of the particles of the square or other objects(like a quick stickman I made) it seems to get really messed up. I've uploaded my code and two compiled versions of it, with force and without force. Your help is much appreciated. Thanks. http://darknight.bluewolf72.com/verlet.zip

Share this post


Link to post
Share on other sites
You need to look at the Constrain code in your stick constraint - there are some problems with it:

1. The loop is in the wrong place - the loop should be over ALL constraints (including non-penetration constraints). As it is the code above _should_ resolve the individual constraint immediately (but see below!), so after the first iteration it wouldn't do anything.

2. The integration of the points is in the wrong place - it should be outside the constraint loop. At the moment if a particle has no constraints it won't get updated at all, and if it is attached to 10 constraints it would get updated 10 times (etc).

3. I also noticed that you need to _set_ the force vector, not accumulate to it, since at the moment it constantly builds up over time, so will make things blow up anyway!

Share this post


Link to post
Share on other sites
Ok, well I took your advice and did some changes and have gotten it a little better. But the square still blows up (just not as quick).

http://darknight.bluewolf72.com/Test.zip

"3. I also noticed that you need to _set_ the force vector, not accumulate to it, since at the moment it constantly builds up over time, so will make things blow up anyway!"

By that I take it you mean I should clear out the forces after each integration ?

I changed it to do that. I did the rest of what you said also, and the above test is the result. It works slightly better but it still blows up.

Any more suggestions ? Im thinking it might be something to do with the square creation.

*Edit* btw: the square works fine if you take out the diagonal constraints, but then it will just collapse of course *Edit*

[Edited by - Shael on December 4, 2004 9:40:32 PM]

Share this post


Link to post
Share on other sites
your constraints are fine, there are just a couple of things...
- don't step the particles in the constraint code. All the particles should be stepped only once, before applying all the constraint.
- reset the force on particles at the end of the integration.

Share this post


Link to post
Share on other sites

This topic is 4756 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