Background
In February of 2021 I wanted to simulate two particles colliding using conservation of momentum. It had been many years since I had done such calculations, but I now wanted to revisit former knowledge. And also show it graphically.
As time went by during spring I got more and more ideas for the simulation and suddenly I could simulate a 2D-box with gas particles of different kinds of atoms. Neat!
Result
You can run the simulation here: https://mauroy.no/particles. Still a work in progress.
Future upgrades
- Implement collision detection using a quadtree. Now every particle checks every other particle, O(n2) scaling. Not good.
- 3D-version using three.js but my own physics engine, just in 3 dimensions.
Screenshot of my early drawings and calculations. It was obvious that I could not calculate if I had sort of two unkowns and only one equation! The trick is to take into account that the collision is elastic, then the energy is conserved!
The final calculation for the momentum for an arbitrary elastic collision between two particles.