This is the flat, top-down twin of the 3D N-body problem simulation: the same gravitational dance of hundreds of masses, each pulling on every other through Newton's law of universal gravitation, mapped onto a plane instead of a rotatable 3D scene. Watching the disk from directly above makes orbital resonances and spiral structure easier to read at a glance, and it renders lighter on low-power or mobile devices since there is no WebGL scene to composite.
F = G·m₁·m₂ / (r² + ε²) — the gravitational force between
two bodies, where G is the gravitational constant,
m₁ and m₂ are their masses, r
is the distance between them, and ε is a
softening term that prevents the force from blowing up when
bodies pass very close.
The three-body problem has no general closed-form solution. Henri Poincaré proved this in 1887, and his work on its unpredictable behaviour planted the seeds of chaos theory — 76 years before Edward Lorenz rediscovered chaos in weather models.
The flat twin of the 3D N-Body Gravity simulation: the same Barnes-Hut gravitational physics, watched from directly above on a 2D canvas — lighter to run and easier to read orbital structure at a glance.
The identical N-body physics as the 3D version — every particle gravitationally attracts every other, accelerated with a Barnes-Hut octree — but projected onto a flat plane. Stable orbits, galaxy collisions, and Solar System dynamics read clearly from a top-down view.
Drag to pan the view, scroll (or pinch) to zoom. Choose a scenario — galaxy disk, galaxy collision, or Solar System — and adjust gravitational constant G, star mass, softening, and trail length with the sliders.
The three-body problem — predicting three gravitating masses — has no closed general solution. Henri Poincaré proved this in 1887, marking the birth of chaos theory, 76 years before Lorenz's weather work.
This is the flat, top-down twin of N-Body Gravity: the same N-body problem physics, in which hundreds of masses each attract every other through Newton's inverse-square law of gravity, drawn on a 2D canvas instead of a rotatable WebGL scene. The accelerations are summed with a Barnes-Hut octree that reduces the cost from O(N²) to O(N log N), and positions are advanced by a leapfrog-style integrator run in small sub-steps — identical to the 3D version underneath. Drag to pan, scroll to zoom, and switch between a galactic disk, colliding galaxies, or a scaled Solar System.
Gravitational dynamics of up to 800 bodies, mapped flat. Each frame the net force on every body is computed from a Barnes-Hut octree (or exact O(N²) summation), then velocities and positions are updated by leapfrog integration. Stable circular orbits, merging discs and chaotic close encounters all emerge from the physics rather than being scripted.
Sliders set the body count (50–800), central star mass (500–8000), the gravitational constant G (0.1–3), the softening ε (0.5–5) and trail length (0–80). A dropdown switches between galaxy disk, galaxy collision and Solar System; a checkbox toggles Barnes-Hut versus direct summation. Use Restart to rebuild, drag to pan and scroll to zoom.
A flat top-down view has no WebGL scene to composite, so it renders lighter on low-power and mobile devices, and the disk's spiral structure and orbital resonances are easier to read without needing to rotate the camera to find a good angle.
The physics is identical — same Barnes-Hut octree, same leapfrog integration, same softened gravity law — only the rendering differs. This version draws bodies on a flat 2D canvas viewed from directly above instead of a rotatable 3D WebGL scene, which is lighter to run and makes orbital structure easier to read at a glance.
It is a numerical model of how many masses move under their mutual gravity. Because each body attracts every other, there is no tidy formula for the motion of more than two bodies, so the computer integrates Newton's equations step by step. This simulation handles up to 800 bodies at once.
A naive N-body calculation evaluates every pair of bodies, which costs O(N²) operations per frame. Barnes-Hut instead builds an octree that groups distant clusters of bodies into a single centre of mass, so a faraway group can be treated as one effective particle. This drops the cost to roughly O(N log N); you can toggle it off to compare against exact direct summation.
The force law, Barnes-Hut grouping and orbital velocities are physically faithful, so the qualitative behaviour — stable discs, tidal tails in collisions and chaotic motion — is genuine. The masses, distances and gravitational constant use simplified simulation units rather than real SI values. It is an accurate teaching model, not a research-grade ephemeris.