Spring-Damper Simulation

Community Forums/Showcase/Spring-Damper Simulation

simonb(Posted 2008) [#1]
I've finally got round to making some of my code respectable enough for publication!

Its a simulation of a system of particles connected with spring-damper connectors - the type of thing seen 'Bridge Builder' and 'Tower of Goo!'. Its not the most optimised code (it was written for readability rather than speed), but I've released it under the GPLv3, so feel free to take a look/modify.

The code and a description of the mathematics can be found at:
http://www.neuronlight.co.uk/springdamper.php


Warpy(Posted 2008) [#2]
Gosh! Proper maths.


Beaker(Posted 2008) [#3]
It's really easy to break your box. I quickly turned it into a single point. Is that what you wanted?


simonb(Posted 2008) [#4]
The structures are rather fragile! Be more gentle with them - try structures other than the box (press keys 1 - 5 for other structures).

You could also try altering the connector breaking strain (connector_bstrain# on line 23) higher values means you can stretch the connectors more before they break.

Also try playing with the values of r# (line 20) and k# (line 21).
r# is the resistence of the dampers - higher value equals less oscillation.
k# is the stiffness of the springs - higher value gives stiffer springs.
Make the values of r# and k# too high, though, and the systen becomes "ill-conditioned" (ie the structure will do strange things!)

Let me know your thoughts...