Sign in to follow this  
Xero-X2

2d Rope

Recommended Posts

Just to start off I'd like to state that I have no experence in physics, but I need to learn how to make a 2d rope simulation. Ive been trying it all day long, with 20 particles, I tried useing springs, but I belive my inmplmentation was incorrect, because the spring system didn't work, and the rope became infinitly long, and soon after the system crashed. so I've decided to ask for some help, and start from scratch, perticuarlly im not even sure I was doing the particles in the rope correcly, In fact I could vouch it was wrong in some why, so thats my first question, 1. could I have an explination of how Gravity, Position, Velocity and the TimeStep size interact. in the past I used something like this: Vel=Vel+Acc(gravity usually); Pos=Pos+Vel*Time; but those were simple visual particle effects and it worked fine for my requirements. 2. givin that my rope is made of seperate particles I am suppost to keep them together with a springs correct? I found the formula F=-K*(Distance-OptimalDistance) I just added this into my velocity originally, but the spring didn't seem to have enought effect to keep the particles close and the system exploded. thanks in advance for any help.

Share this post


Link to post
Share on other sites
for every particle
vForce = 0
for every neighbour
vForce += fK * ( fDistToNeighbour - fRestDistToNeighbour ) * vDirToNeighbour
end for every neighbour
vAcc = vForce / fMass
vVel += vAcc * fDt
vPos += vVel * fDt
end for every particle

Force between neighbours is the same but opposite if the neighbours are connected with springs so there's room for optimization here.

JD

Share this post


Link to post
Share on other sites
Many thanks for both of your help, I have it working decently,

the springyness of the rope is slightly bugging me, but its not unreasonable. I did have some rather nasty problems where the program crashed from Floating Point Underflows, but I belive I have corrected it.

thanks again.

Share this post


Link to post
Share on other sites
to have a much more rigid rope (no spring), you can use Jackobsen's technique.

http://www.ioi.dk/Homepages/thomasj/publications/gdc2001.htm

Share this post


Link to post
Share on other sites

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