Barnes–Hut Gravity (2D)

Preset

Parameters

Live stats

Bodies0
Tree nodes0
Tree depth0
BH force calcs / frame0
Brute-force equiv (n²)0
Speed-up—
Barnes-Hut approximates N-body gravity: a quadtree is rebuilt every frame, each internal cell aggregates the total mass and center-of-mass of the bodies inside it, and the force on each body is computed by walking the tree — a distant cell is treated as one point mass when size / distance < θ, otherwise the walk recurses into its four children. Cyan cells were approximated as a single mass; the force-calc counter shows the resulting O(n log n) count against the O(n²) brute-force count it replaces.