Inspiration

Orbits are easy to describe and hard to feel. A textbook says every mass pulls on every other mass. It doesn’t let you drop a new one into a stable system and see it collapse. I wanted a toy that makes that visible in a few seconds, with no install and no sign-up.

What it does

Orbit Sandbox is an N-body gravity simulator in the browser. You load a preset system, drag on the field to launch a new body, and watch the system react. The drag sets the body’s speed and direction. While you aim, time holds and a dotted line previews the body’s path, including how it pulls on the others. You can change the mass of the next body, speed up or slow down time, turn trails on or off, and choose whether bodies merge when they touch. A readout shows the body count, the simulation time, and the energy drift.

How we built it

It is one HTML page with a canvas and no libraries. The physics uses velocity Verlet with a fixed time step. Gravity is softened so close passes don’t produce huge forces. The energy readout uses the same softened potential, so the drift number measures how well the integrator behaves. The launch preview copies the whole system and runs it forward at a larger step, so it accounts for every body’s pull.

Challenges we ran into

Keeping close encounters stable took the most care. Softening and merge-on-contact keep the simulation going, but merging does not conserve energy, so the energy baseline resets when a body is added, merged or lost. I also made the preview run on a copy of the full system, which is what keeps it accurate.

Accomplishments that we're proud of

In a headless test of the figure-eight preset, energy changed by about 2×10⁻⁷ over roughly 20 orbits at a step of 0.1.

What we learned

Energy drift is a cheap and honest check on a simulation. When the drift stays small, the orbits are trustworthy.

What's next for Untitled

Zoom and pan, a body inspector, saving and sharing a system as a link, and a higher-order integrator for tight encounters.

Built With

Share this project:

Updates

Submission history