← Portfolio
Gravity Grid
An n-body gravity simulation: a galaxy of planets that attract, collide and merge. Written three times between 2023 and 2025.
600 bodies left. Drag to pan, scroll to zoom. Planets that touch merge into one.
Bodies: 600
Spin: 1.10 (1 holds together, higher flies apart, lower collapses)
Temperature: 1.0
Every body pulls on every other with the inverse-square law, so the cost grows with the square of the count. Raise the body count and watch the frame rate to feel it. Nearby planets pull hard on each other, so they clump and merge into bigger ones; the count above keeps track.