This is a physics simulation I wrote some years ago when I was into that sort of thing.
Feel free to inspect and make fun of my awful code