This is a genuine gravitational N-body simulation of a disk galaxy, viewed from directly above. It is the mechanical twin of the 3D Spiral Galaxy simulation, but where that version places 80,000 points on a fixed procedural spiral shape, every star here starts on a physically motivated orbit and is then pulled around purely by real gravity, frame after frame — the spiral arms you see are computed, not drawn.
v²(r) = GM_bulge/(r+ε) + GM_halo/(r+a) — the rotation-curve
speed at radius r. The first term falls off with distance like a
point mass; the second, from an isothermal halo, flattens out at large
r instead of decaying — exactly the flat rotation curves measured
in real galaxies, and the classic evidence for dark matter.
Spiral arms cannot be made of the same stars forever — differential rotation would wind them into a tight coil within a few galactic rotations. Real arms persist because they behave like density waves: a slow-moving traffic jam that different stars pass through, brighten in, and leave, over and over.
A real gravitational N-body simulation of a spiral galaxy viewed from above: a Barnes-Hut quadtree computes genuine star-on-star gravity, a bulge-plus-halo rotation curve drives differential rotation, and spiral arms wind and evolve on their own — computed every frame, never drawn.
Stars orbit under real Newtonian gravity from a Barnes-Hut tree, seeded on a rotation curve built from a central bulge plus a flat-rotation dark-matter halo. Because inner stars have far higher angular speed than outer ones, an initial spiral perturbation shears and self-reinforces into trailing arms.
Drag to pan, scroll to zoom. Adjust star count, bulge and halo mass, velocity dispersion, arm seed, gravity G and softening. Raise the halo slider live and watch the outer rotation speed flatten out — the classic dark-matter signature.
Differential rotation would wind a fixed set of spiral-arm stars into a tight coil within a few galactic rotations. Real arms survive because they behave as density waves — a slow-moving jam that different stars pass through and light up, over and over.
This is a top-down twin of Spiral Galaxy built on a different mechanic: instead of scattering points along a fixed procedural spiral, every star here starts on a physically motivated near-circular orbit and is then evolved by real N-body gravity. A Barnes-Hut quadtree sums the mutual pull of the bulge and every star each frame in O(N log N) time, a static isothermal dark-matter halo keeps the rotation curve flat at large radius, and differential rotation — inner stars sweeping around far faster than outer ones — shears an initial two-armed seed perturbation into a genuine, evolving spiral.
Real gravitational dynamics: rotation-curve initialisation from bulge + halo mass, Barnes-Hut N-body integration, and spiral structure that emerges from differential rotation acting on a density perturbation rather than from a hard-coded spiral formula.
Sliders set star count, bulge mass, halo (dark matter) mass, velocity dispersion, the initial arm seed fraction, gravitational constant G and softening ε. G, softening, bulge and halo mass apply live; star count, dispersion and arm seed take effect on Restart. Drag to pan, scroll to zoom.
Because orbital angular speed falls with radius, any straight line of stars drawn through the disk winds into a spiral within a few rotations — the same shearing that keeps re-shaping the arms here, frame by frame, as physics rather than animation.
The 3D version places up to 200,000 points directly onto a procedural logarithmic-spiral formula and rotates the whole disk rigidly — a geometric model, not a gravity solver. This 2D version instead integrates real Newtonian gravity between the bulge and every star with a Barnes-Hut quadtree, so orbits, differential rotation and spiral winding are all computed outcomes, not preset shapes.
In a galaxy, stars closer to the centre complete an orbit much faster (in angle per unit time) than stars further out. If you start with a straight or lightly perturbed line of stars, that speed difference shears it into a trailing spiral within a few rotations — exactly what the "Arm seed" stars do here once the simulation starts running.
It adds a smooth, non-responsive background mass whose gravity flattens the rotation curve at large radius, following v² = GM_halo/(r+a). Raise it while the simulation runs and the outer stars visibly speed up and stay roughly constant with radius instead of slowing down — the same flat-rotation-curve evidence that convinced astronomers most galactic mass is invisible.
It is real: every star's acceleration each frame comes from summing Newtonian gravity (softened at short range) from the bulge and every other star, sped up with a Barnes-Hut quadtree instead of being approximated away. You can even toggle Barnes-Hut off to fall back to exact O(N²) pairwise summation and confirm the results are consistent.