b2KIT

N-Body Gravity Simulator

Simulate gravitational interactions between N bodies. Create solar systems, binary stars, and galaxy-scale simulations with trail rendering.

Tested tool guide Tested browser tools Checked August 16, 2026

What N-Body Gravity Simulator does and how it behaves

Set up multiple bodies with masses, starting positions, and velocities, then advance simulated time to observe their mutual gravitational motion and rendered trails. The display helps compare orbit shapes, shared motion around a center of mass, close encounters, and ejections. A common surprise is that placing one body beside another does not create a stable orbit by itself. The starting speed and direction must suit the selected masses and separation; even a small mismatch can produce an ellipse, escape trajectory, or very close encounter.

How the result is produced

1

Initial conditions define one trajectory

Mass determines each body's gravitational influence, while position and velocity define the starting geometry and momentum. A run represents the evolution of that exact configuration, not a general solution for all similar systems. Reversing one velocity component, changing one mass, or moving a body creates a different problem. For useful comparisons, change one initial value at a time.

2

Gravity couples every body's motion

Each body attracts the others, with attraction increasing with mass and decreasing rapidly as separation grows. The resulting acceleration changes each body's velocity and position as simulated time advances. A planet therefore moves its star as well as being moved by it, although the heavier body accelerates less. Trails show paths through the displayed coordinate frame; they do not by themselves establish orbital stability.

Good uses

  • Adjust the sideways velocity of a two-body system to compare elliptical, near-circular, and escaping paths.
  • Create a binary-star configuration and observe both stars moving around their shared center of mass.
  • Explore a three-body close encounter to see scattering, exchanges, ejection, and sensitivity to small initial changes.

Limits and checks

  • A smooth trail is not evidence of numerical accuracy. Very close approaches produce rapidly changing forces and can require finer time resolution than a wide, slowly changing orbit.
  • Confirm the displayed units before entering physical data. Mass, distance, velocity, and time must form a consistent unit system, or a familiar solar-system configuration can evolve on an unexpected scale.
  • Do not assume the simulation includes relativity, physical body radii, impacts, tidal forces, drag, or fragmentation unless the interface explicitly identifies those features. A crossing of trails is not necessarily a modeled collision.

Common questions

Can a closed-looking trail prove that an orbit is stable?

No. It only shows that the path remained bounded during the displayed interval. Perturbations may accumulate over many revolutions, and a trail that initially repeats can later precess, become chaotic, or end in a close encounter. Test a substantially longer duration and compare runs at finer time resolution before treating apparent stability as meaningful.

Why does the star move when a planet orbits it?

Gravity acts mutually, so the planet attracts the star while the star attracts the planet. Both move around their common center of mass. If the star is much heavier, its path is correspondingly smaller and may look like a wobble. A view centered on the star can make that motion less obvious, but it does not remove the underlying interaction.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools