Skip to content

Gravity simulator using Newton's Law of Universal Gravitation, made to help teach physics

License

Notifications You must be signed in to change notification settings

RustWorks/gravity-sim-v2

 
 

Repository files navigation

gravity-sim-v2

Gravity simulator using Newton's Law of Universal Gravitation, made to teach physics

The goal is for this to run on the web and to otherwise be as easily accessible as possible.

Right click a body to edit it and graph its properties.

The GUI uses imgui-rs; using it you can create new bodies, adjust existing bodies, or change variables like the timestep.

compiling/running

precompiled binaries

There are binaries for Windows and Linux in the releases tab on Github, for MacOS you'd have to compile yourself, but feel free to send me the compiled binary to put on Github.

compile yourself

Install the rust compiler toolchain via rustup

cd to the folder of this repo and run cargo run --release.

gifs

The start scenario has a simple orbit

You can graph various properties such as speed (more to come)

There are previews/predictions when you create a new body

The orbit changes due to integration error, but the timestep is adjustable

You can make trails relative to the selected object.

Negative mass and negative timestep are cool

You can save and load preset scenarios; binary and nested systems are included.

details

Made with ggez and specs

Fully inelastic collisions in which the position of the collided body is decided by the mass weighted average position of the two collided bodies. The new radius is decided by adding the volumes.

Uses Verlet integration, with basic Euler integration energy is not conserved so orbits gradually increase in radius whereas with Verlet integration (and I think implicit Euler), all that happens is the orbits slightly shifting.

About

Gravity simulator using Newton's Law of Universal Gravitation, made to help teach physics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%