Skip to content

BaGreal2/gravitation-particles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gravitation Particles

A Barnes-Hut implementation of n-body gravitation simulation in Rust.

Gravitation Particles Demo

Running the project

The video rendering feature is implemented using the ffmpeg, so you will need that installed. Assuming you also have cargo installed, all you need to run a project is simply:

cargo run

Usage

Usage is pretty simple:

  • In consts.rs you can adjust window and world resolution as well as some other params

  • In main.rs you can create "galaxies" using the create_galaxy() or spawn_circle() functions or by just inserting particles into particles vector

  • After program is in run, you can see fps in the window title

  • To start rendering record you need to press R on your keyboard and then S to stop the record. After the recording process is stopped, video will be automatically created from screenshot images and saved into results folder in the project root directory

  • To move around the canvas you can use mouse scroll wheel to zoom in/out and hover cursor onto the edges of the window to move around

Algorithm

Barnes-Hut simulation Wiki

The Barnes-Hut algorithm is a way of optimizing n-body simulations. It allows to group particles into groups if they're enough far away to be considered as a single object. The complexity of this algorithm is O(n log(n)) compared to a Direct algorithm which complexity is O(n2)

About

A gravitation simulation with Barnes-Hut algorithm implementation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages