A gravitation simulation with Barnes-Hut algorithm implementation.

Overview

Gravitation Particles

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

10k-10k-collision.gif

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() function 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)

You might also like...
Terminal UI implementation and types for the Dark Forest game

dark-forest.rs Terminal UI implementation and types for the Dark Forest game Development We use the standard Rust toolchain cargo check

Rust implementation of Another World (aka Out of this world) game engine
Rust implementation of Another World (aka Out of this world) game engine

RustyWorld Rust implementation of Another World (aka Out of this world) game engine. I wanted a fun project to challenge myself while learning Rust, a

Implementation of the great book Ray Tracing in One Weekend in Rust.
Implementation of the great book Ray Tracing in One Weekend in Rust.

Ray Tracing in One Weekend (Rust) Implementation of the great book Ray Tracing in One Weekend in Rust. Fun easy way to pick up and learn Rust (was rou

A Rust implementation of the legendary solitaire game
A Rust implementation of the legendary solitaire game

Freecell Yet another implementation of the legendary total information solitaire. Play patience like it's 1991, complete with sights and sounds. Build

Game of life implementation written in Rust.

Game of life Game of life implementation written in Rust. Part of my journey in learning Rust. Pattern files The patterns are based on the example pat

A simple implementation of Conway's Game of Life using Fully homomorphic Encryption

Game of life using Fully homomorphic encryption A simple implementation of Conway's Game of Life built using Zama's concrete-boolean library. Build Ju

An implementation of the Game of Life

Lifeee – An implementation of the Game of Life I realized this application to keep learning Rust, discover the front-end library Yew, and because I’m

A simple, very minimal Minecraft server implementation in Rust.
A simple, very minimal Minecraft server implementation in Rust.

A simple, very minimal Minecraft server implementation in Rust. For a simple Minecraft server that isn't supposed to do much (for example, a limbo ser

Rust implementation of the Nomic Bitcoin sidechain

Nomic Bitcoin Bridge testnet v0.3.0 (codename "gucci") Guccinet In this testnet, we've added two core featues: staking and Bitcoin integration. Full s

Owner
Artem
just a dev
Artem
A sci-fi battle simulation implemented in the bevy engine.

Bevy Combat It's a bevy port of my ECS Combat Unity demo. Check out the web demo in your browser. You can use the - and = keys to speed up and slow do

ElliotB256 47 Dec 22, 2022
Abstreet - Transportation planning and traffic simulation software for creating cities friendlier to walking, biking, and public transit

A/B Street Ever been stuck in traffic on a bus, wondering why is there legal street parking instead of a dedicated bus lane? A/B Street is a project t

A/B Street 6.8k Jan 9, 2023
3d car simulation in rust

3d car simulation in rust This project is developed with intention to learn: programming on rust, computer graphics, physics simulation, geometric alg

Alexi Chepura 45 Dec 31, 2022
Wheeled vehicle simulation using Bevy engine with Rapier's joints

⚠️ Legacy branch! ⚠️ 'master' branch is currently broken due to migration to newer rapier and bevy_rapier so unless you want to compare old and new ve

null 29 Nov 14, 2022
A networked (p2p), cross-platform physics simulation example using rollback netcode

bevy_gaff (work in progress) bevy_gaff is an attempt at making a networked (p2p), cross-platform physics simulation using rollback netcode. It synchro

Johan Klokkhammer Helsing 13 Sep 5, 2023
A velocity-based falling sand simulation built with Rust and Bevy

⏳ Bevy Falling Sand A velocity-based falling sand simulation built with Rust and Bevy! This simluation uses bevy_rapier to generate colliders that reg

Tomato 7 Oct 30, 2023
Rust boids simulation using Reynolds model running with Bevy engine.

example.mp4 About Rust boids simulation using Reynolds model running with Bevy engine. The following parameters can be updated while the simulation is

Daniel Di Dio Balsamo 7 Nov 15, 2023
An implementation of the Jump Flooding Algorithm for the Bevy engine.

bevy_jfa The Jump Flooding Algorithm (JFA) for Bevy. Features This crate provides an OutlinePlugin that can be used to add outlines to Bevy meshes. Se

null 20 Aug 19, 2022
A no-frills Tetris implementation written in Rust with the Piston game engine, and Rodio for music.

rustris A no-frills Tetris implementation written in Rust with the Piston game engine, and Rodio for music. (C) 2020 Ben Cantrick. This code is distri

Ben Cantrick 17 Aug 18, 2022
An (unofficial) open source Rust implementation of the Discord Game SDK.

⚔️ discord-sdk An (unofficial) open source Rust implementation of the Discord Game SDK. Why not use this? This project is not official and is using a

Embark 86 Dec 23, 2022