An interactive simulation of planetary formation based on the Kant-Laplace nebular hypothesis. Watch thousands of rocks orbit a sun, collide, and merge to form planets over millions of years.
Try it live at douwe.com/projects/kantlaplace
- Newtonian physics: Realistic orbital mechanics with gravity from both the sun and rock-to-rock interactions
- Collision detection: Spatial hashing for efficient O(n) collision detection
- Mass conservation: Rocks merge on collision, conserving momentum
- Configurable rock counts: 3k, 10k, 30k, or 100k initial rocks
- Real units: Mass displayed in Earth masses, distances in millions of km
- Speed control: Exponential speed slider from 1x to 25,000x
- Overview mode: Hold Shift to see the top 25 largest bodies with orbit trails
- State persistence: Simulation auto-saves to localStorage
- Drag: Pan the view
- Scroll: Zoom in/out
- Click: Select a rock to see details
- Space: Pause/resume
- Shift: Overview mode (shows largest bodies with trails)
- R: Reset view
- F: Fullscreen
The simulation models:
- Central star gravity:
a = G * M / r² - Rock-to-rock microgravity with softening to prevent numerical slingshots
- Inelastic collisions with momentum conservation
- Center of mass calculation for merged bodies
Total system mass is approximately 30 Earth masses, enough to form gas giant cores.
world.js- Physics simulation (Rock class, World class, collision detection)view.js- Rendering and UI (canvas drawing, controls, HUD)
MIT
