/N-Body-Simulator

N-Body simulator using the Barnes-Hut algorithm.

Primary LanguageJavaScript

N Body Gravity Simulator

This simulator uses the Barnes-Hut algorithm to simulate gravity on n bodies with logarithmic complexity!

Demo

To see the n-body simulator in motion, visit https://kelvin-chen.github.io/N-Body-Simulator/!

Controls

  • Mouse click - insert particle at mouse click location
  • Spacebar - pause/unpause simulator (default paused)
  • [ and ] - slow down and speed up the simulator
  • t - view the Barnes-Hut quad tree
  • r - reset simulator
  • You can also generate some interesting default patterns with the particles:
    • s - square
    • S - spiral
    • c - circle
    • e - ellipse