Bellaard.com

Barnes-Hut Simulation

This is a simulation of 1000 point mass particles interacting through gravity using the Barnes-Hut algorithm. You can pan by dragging with your mouse, and zoom by scrolling with your mouse wheel. If you're on a touch device you can pan & zoom in the standard way. The threshold input determines how accurate/expensive the simulation is. If it is set to 0 the simulation is 100% accurate and will be computationally expensive. How higher the threshold is, the more the gravity calculations will be approximated, and how less computationally expensive the simulation will be. Effectively, the threshold parameter determines the amount of gravity calculations. This amount is determined on every step of the simulation, and can be seen below. The lower this amount is, the less computationally expensive the simulation will be. The time step and gravity constant of the simulation can also be changed below. A higher time step translates to a faster but more approximative simulation. If it is set too high the simulation can even become unstable!