/gravity-sim

Newtonian gravity simulator

Primary LanguageJavaScript

About

A rudimentary Newtonian gravity simulator. Allows the user to create a system of particles which are attracted to each other using Newton's law of universal gravitation.

Controls:

click - create a particle.

click + drag - create a particle with initial velocity.

shift + drag - pan the camera.

up arrow - double the current mass.

down arrow - halve the current mass.

left arrow - increase the gravitational constant.

right arrow - decrease the gravitational constant.

f - focus the viewport on the most massive particle. This particle will have its velocity forced to zero to make the velocities of other particles relative to it.

v - draw helper lines on all particles showing their velocity.