2d Rope

Started by
3 comments, last by oliii 19 years, 8 months ago
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.
"I seek knowledge and to help those who also seek it"
Advertisement
I once wrote simulator that simulates big rope with really many particles. It's written in pascal but should be readable for c++ programmers.
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
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.
"I seek knowledge and to help those who also seek it"
to have a much more rigid rope (no spring), you can use Jackobsen's technique.

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

Everything is better with Metal.

This topic is closed to new replies.

Advertisement