Adapting d3.forceCollide to do elastic collisions (like billiards). You can click and drag the balls.
High school physics refresher from Wikipedia. Inspired by chatting with Robert Monfera and Chris Given’s riffing on d3.forceCollide.
- Make it a proper es6 module
- Log net momentum and kinetic energy for debugging
- Balls can tunnel through each other or spawn atop each other, which somehow leads to non-conservation of momentum
- In any case, momentum won’t be conserved here because of the wall-bounces & dragging. A momentum-conserving finite-area alternative to walls would be to make the window a torus, I think, right?
- Generalize to other shapes?
- Relativistic! Lol.
- Actual billiards game; then add gravitational forces and other twists…