Disc galaxy with quadtree cells
Error and work against opening angle

Barnes-Hut Tree Code for a Spiral Galaxy: Quadtree Grid and Error Against Opening Angle (2D)

Computing the gravity of every star on every other star costs N squared operations; the Barnes-Hut tree code replaces distant groups of stars by a single point mass and needs only about N log N. Set the number of stars, the opening angle theta, the softening length and the initial spiral and watch a Blender-built hologram table carry a rotating galaxy whose quadtree grid is drawn beneath it, while the force error against direct summation, the interaction count and the rotation curve update live. Checked against direct summation, error growth with theta, N log N scaling and the Kepler period of a leapfrog orbit.

Made with 🟠 Blender