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