Apparently there is one weird trick to calculating the result of rigid body collisions like this: you simply have to consider the nature of contact forces. They are inflicted at the point of contact, along the contact normal, for a brief instant. This determines the change in momentum and angular momentum up to one scalar multiple, which itself may be determined by conservation of energy (assuming the collision is elastic). This simulation here has big flaws though, because I'm a bad programmer.
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!