Thing well made: fast physics modeling of 2D cloth in javascript
Andrew Hoyer’s javascript skills are awesome as you can see with this 2D cloth physics simulation with gravity written in Javascript. He uses Taylor expansion to avoid square roots in javascript (which are expensive). The code he’s written is also a thing well made — mostly very clear, concise code (except the occasional curiosity like ‘inv_m’) which by and large doesn’t need any docs.
What makes this simulation special is the speed at which everything is computed. Javascript (the language this is written in) is not exactly the most efficient language for this type of computation. This being said, much time was spent squeezing out every little detail that slows things down.
One of his inspirations is the 2D cloth simulation in a java applet using the Processing library by JRC313.com
NOTE if the simulation below is jerky, try some of the faster browsers such as Google Chrome * or Safari as their javascript support is faster than Firefox / IE currently as of March 2010.
* In the interests of full disclosure this is my own opinion but Google is my employer. But Chrome is still faster
