Hello,
Sodaplay is a popular mass and spring simulator:
http://sodaplay.com
However, long before that was xspringies by Doug DeCarlo:
http://www.cs.rutgers.edu/~decarlo/software.html
Seeing these models in action for the first time totally blew my mind.
When I see stuff like this, I sometimes get a strong urge to find out
"how does it work". Peeking at the source code was a little
discouraging. I set out to understand the implementation of xspringies.
At the time I was mainly programming in Factor. To start simple I did an
implementation based on Newton's method. To my amazement, Factor was
able to run the models with decent speed! But... because I was using
Newton's method, the models would explode if you cranked the time-step
too high... Still I pleased with the results and also impressed with the
implementation of Factor.
Well, lately I've been getting back into Scheme. I just had to know; can
Scheme handle springies? I mean, a *pure* Scheme implementation; no
calls out to C based physics libraries. The answer is YES! Ikarus runs
the simulations with flying colors. The entire engine weighs in at 508
lines of Scheme. Moreover, the implementation is now using a fancy
Runge-Kutta numerical method so you can crank the time-step much higher
than before without the model blowing up. The engine source:
http://github.com/dharmatech/agave/raw/master/demos/springies.sls
The engine and a few demos have been checked into Agave. Each of the
following will kick off a demo:
ikarus --r6rs-script ~/agave/demos/springies-belt-tire.scm
ikarus --r6rs-script ~/agave/demos/springies-ball.scm
ikarus --r6rs-script ~/agave/demos/springies-2x2snake.scm
NOTE!!! For those who have already setup Agave, you probably already
added the 'agave/' directory to your Ikarus or Ypsilon library path. Now
you'll also need to add 'agave/demos/' to the path as well. The README
has been updated to reflect this.
I have the default time-step tuned to a value which works well on an
older generation machine running Ikarus. If it's too fast, you can use
the keyboard (keys '2' and '3') to adjust the time-step.
It pleases me to no end that application domains such as physics
simulation is brought within reach of Scheme hackers by high-performance
implementations such as Ikarus.
Please give the springies demos a go! I'd love reports on whether or not
they work for you.
Ed
PS: Ypsilon can also handle these demos! However, you will have to crank
up the time-step accordingly to get a decent speed.
PS: The model data comes from the original xspringies. Thanks to Doug
DeCarlo for such a cool and inspirational program!