Skip to content

aleamb/gravity-lab

Repository files navigation

gravity-lab

Gravity laboratory.

A toy to play with gravity.

The orbits are rendered using Euler's integration, and pre-orbit rendering (while placing body) is calculated by Verlet's integration.

gravity-lab

Features

  • Create objects and set position and velocity using mouse.
  • Modify mass, velocity vector (x and y components), position, diameter and color for each body.
  • Two presets with Sun and Earth parameters.
  • Modify G.
  • Set scale, velocity scale, grid and time scale.
  • Create bodies providing mass, velocity and position parameters.
  • Pre-draw orbits while placing the body.
  • Trace orbits.
  • Infinite universe.
  • Change body values in real time.
  • Body's gravity enable/disable.

Pre-requisites to build and run.

  • Install Nodejs
  • Browser with HTML5 support.

Build and run

  1. CD to project directory. Install dependencies.
npm install
  1. Build
npm run dist
  1. Run

Open index.html in your browser, or run

npm run watch

This last command will open a browser and will load index.html automatically.

License

Gravity-lab is licensed under the MIT license. (https://opensource.org/licenses/MIT)