It’s not quite the same as the type of physics simulation a physicist would use, because generally a physics engine will do computations in real time, so the algorithms need to be fast. The algorithms in (real-time) physics engines will cut some corners to acheive an effect that is physically plausible to the eye, even if it’s not what would really happen. Usually they are used in game development but there are, of course, other applications also.
After playing around with physics engines and creating modest simulations of my own, I decided to see if I could pool all of my work into a little library, that hopefully could evolve into something people would find useful. The result is PhysicsJS. It’s generally well documented and the code is written as cleanly as I could. It’s also modular, so the bare-bones functionality is only 32 KB (minified) and the (current) full functionality is 52 KB (minified), but it was written with AMD in mind, so you can include exactly what you need to get the job done with requreJS. It’s also extendable; I wanted to make sure that it would be easy to mixin new functionality of any kind, and replace what isn’t suitable. I’m hoping people will start writing plugins to extend the capabilities, which is an exciting prospect! It’s also fun to use. Only time will tell whether or not it’s an intuitive API… but I’d like to think it is.
Anyways, go check it out and play around. There are some cool demos of the functionality. I’m really interested to see what people think of it so send me your feedback. If you’re interested in contributing, I’d love people to make some plugins to extend the functionality, and also fix some of the quirks in its algorithms.