Quite simple and fast simulation of dynamics can be reached with Position Based Dynamics. Instead of modeling forces and masses directly, the focus is on position constraints and projections. Already with very simple rules, one can get impressively realistic-seeming simulations. With enough self-avoiding points, it almost seems like a splashing liquid.

Touch the screen or move the mouse around to start and interact. Note that scrolling with a touchscreen requires to touch ouside the canvas area. Elements either have a minimum distance (being pushed away from each other) or a maximum distance (being contained with one another).

The code can be found at https://github.com/sven-hoek/interactive_animations/.

Inspired by Sublucid Geometry’s blog post.