Hey HN,
@atan2 submitted a great post 4 days ago about 2D rigid body collisions (https://news.ycombinator.com/item?id=40463764).
For what it's worth, here is a minimalistic simulation that I coded last year using TypeScript and HTML Canvas:
- Code: https://github.com/vandrieu/canvas-bouncing-ball
- Demo/Result: https://vandrieu.github.io/canvas-bouncing-ball
The main challenge was how to determine the angle and speed of each ball after a collision at a given angle.
I found the relevant theoretical material in the 2009 paper titled "2-Dimensional Elastic Collisions without Trigonometry" by Chad Berchek: https://www.vobarian.com/collisions/2dcollisions2.pdf
Please feel free to copy and use the code any way you wish.
0