# Taught rope

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

## Recommended Posts

Ok, so I have a 2D rope simulation implemented using springs, very similar to the NeHe tutorial. It works well, except it's too slack. It moves too slow and can stretch waaaay too far. I have the k of the springs as high as they can go before shit just goes crazy.. I tried increases the mass of the segments but it just slows it down until I increase k and friction again as far as it will go, but it ends up at pretty much the same as it was. I'm just wondering how I can make a really TIGHT rope. Is there some special balance I need between the mass, k and friction or do I need to add something else? Basically I want it so if the rope is of length 10 at equilibrium, it won't stretch any further than, say 14. Thanks in advance

##### Share on other sites
If you use a more stable integrator, you can make the elasticity constants as large as you want. You can effectively make them infinite.

Take a look at verlet integration, for instance as described here.

##### Share on other sites
If you actually want an unstretchable rope, you'll need to use hard constraints (with a solver), not spring forces.

##### Share on other sites
Yes. You can solve a fully constrained rope (where the lengths between rope nodes is held constant) in linear time. The idea is to solve for the tensions in the rope, and use those to find the node accelerations.

The basic idea is, if d_i is the vector from node i to node i+1, that d_i^2 = const., so that dot(d_i, a_i)+dot(v_i, v_i) = 0, where v_i = first derivative of d_i, and a_i = second derivative of d_i.

For each node, newton's laws say that m*accel_i = d_i*T_i-d_(i-1)*T_(i-1)+F_i. We can use the constraint equation from above to eliminate the accelerations, leaving only the tension (T) in our equations. For every node equation, we involve three adjacent tensions - resulting in a tridiagonal system, solved in linear time! You have to fill in the details, and be careful about B.C.s. Also, you will need to keep weak (very) springs in the system still, because round-off and integration errors will gradually erode the constraint satisfication - the springs fix this. But they don't need to be strong, so won't cause instabilities.

Even if you go with the spring approach only, don't forget at least weak dampers to destroy resonant modes (in some cases this could cause your rope to go haywire). While not required, they also make things look more realistic because real ropes have some dissipation.

##### Share on other sites
Hi ganoosh,

Here's a ~ 500 line c++ soft body simulation using damped springs and a very stable integration scheme (stabler than rk4). If you read the code carefully, you'll be able to pick out everything you need :-)

http://www.jernmager.dk/stuff/cpp/soft_body_03.zip
http://www.jernmager.dk/stuff/cpp/softbody_glut.zip

@gpu_fem

I'm very interested in learning more about this! Can you please explain this in a little more detail, or at least link to a working code sample or a paper explaining this for dummies?

Cheers,
Mike

##### Share on other sites
Quote:
 ...a very stable integration scheme (stabler than rk4)

Looking through the source... velocity verlet. For the curious.

...

I actually did a presentation on what gpu_fem is talking about I think. I have my powerpoint here. And you *may* need this plugin to see the math render right.

The basic idea is that your system of colliding (or in this case jointed) bodies is a single system of linear equations for some unknown impulses. Construct the system and solve. In general solving is a O(n^3) process, but for sparse systems the cost goes way down. And most collision "islands" only have a few contact points per body. Which makes the systems very sparse.

For instance, something like a rope (or in my presentation, Newton's Cradle) is a very simple system which forms a tridiagonal matrix, which can be solved for in linear time through various numerical methods (check out Chapter 2 of Numerical Recipes for a how-to of solving linear systems).

If you use my presentation's format, just assume that the coefficient of restitution between bodies is 0. And be sure to add another "collision" for the lateral (instead of normal) direction for contacts. Otherwise the chains in your rope would drift laterally from each other.

##### Share on other sites
Hi Numsgil,

Unfortunately I can't read your powerpoint - it doesn't go well with open office. Do you know of any relatively simple code samples illustrating these concepts availabe on the web? I would very much appreciate any help getting startet with using constraints in my physics sims.

Cheers,
Mike

##### Share on other sites
I am writing some code / writeup using hard constraints to solve for rope physics instead of springs - need a few more hours though. If there is significant interest (and novelty) I can prepare it to a full blown tutorial.

##### Share on other sites
Quote:
 Original post by gpu_femI am writing some code / writeup using hard constraints to solve for rope physics instead of springs - need a few more hours though. If there is significant interest (and novelty) I can prepare it to a full blown tutorial.

That would be awesome man. That would probably be the easiest way for me without redesigning everything I have from the ground up haha

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
17
5. 5

• 14
• 29
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631773
• Total Posts
3002265
×