This simulation uses the Barnes-Hut method to simulate the gravitational forces acting on each object. This method groups bodys together to simplify calculations as the objects get farther away, making use of a Quad Tree in order to store the objects' relative positions. By using this algorithim I was able to move from a simulation with O(n2) complexity to one with O(n log n) complexity drastically decreasing computing cost.
Code
Made 2019