A long long time ago on a computer long since retired …
Given the number of objects, create a ‘star’ and then place objects at random radii from the star, calculating their orbital velocity relative to the star.
It was one of my earliest, more complete sketches that I worked on back then. Funny aspect, this was before I knew about version control software. I would use a rudimentary version of semantic versioning in the filenames, and include a short description at the end of each filename. I’ve lost all but a few versions to time, but I worked up to
Some features I remember being proud of at the time:
- Generating moderately stable orbits for a single-star and binary-star systems.
- Allow for reset / restart the simulation with the same data (when something interesting happened).
- Detect collisions and preserve momentum (not sure if I modeled slight loss of energy due to heat).
- Zooming. I remember this being an interesting challenge.
- Lock the perspective on one of the objects.
It was a naive implementation, didn’t use anything like a Quadtree data structure. I think I did manage to avoid
O(n^2) by only calculating the gravitational force per pair once per iteration, bringing it back to
O(n log n) if I remember my Big O computational complexity.
For posterity, I’ve posted the source code to this repo, but I don’t have Flash anymore. So I can’t even open the
.fla source files correctly. But that’s okay. Google Chrome is also dropping support for Flash altogether at the end of 2020 … so all good things must come to an end.
Place two ‘star’ objects (in terms of mass) in orbit around their center of mass. Then for the generated objects, place them in orbit around one of the two stars, or around the center of mass of the two stars at a more distant radius.
Spiral planetesimal arrangement
Place objects in spiral pattern, with no initial velocity … to see how the system collapses in on itself.