https://github.com/mwja/rust-galaxies
Simple galaxy/star simulation engine in Rust
https://github.com/mwja/rust-galaxies
galaxies planets rust rust-lang simulation star velocity
Last synced: about 1 month ago
JSON representation
Simple galaxy/star simulation engine in Rust
- Host: GitHub
- URL: https://github.com/mwja/rust-galaxies
- Owner: mwja
- Created: 2021-05-04T18:33:53.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-14T20:16:38.000Z (about 4 years ago)
- Last Synced: 2025-04-30T07:50:03.824Z (about 1 month ago)
- Topics: galaxies, planets, rust, rust-lang, simulation, star, velocity
- Language: Rust
- Homepage:
- Size: 19.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Galaxies
Simple galaxy simulation in Rust## Features
- Attempts to handle collisions by checking their relative velocities
- Traces future paths *by simulating seperately* (as shown below)
## Config
The default configuration file looks like:
```yaml
galaxies:
- star:
mass: 2000000.0
color: [1.0, 1.0, 0.0, 1.0]
planets:
distance:
min: 10
max: 30
mass:
min: 1
max: 50
number: 250
position: [60.0, 60.0]
direction: 1.0
- star:
mass: 1000000.0
color: [1.0, 1.0, 0.0, 1.0]
planets:
distance:
min: 10
max: 30
mass:
min: 1
max: 50
number: 250
position: [-60.0, -60.0]
direction: -1.0
scale: 1.0
time_scale: 1.0
```This has 3 components:
- `galaxies`, which refers to the structures that will be generated. Each contains information about the central star, planets' distances and masses, the position in the world and the direction of the planets' orbits. Planets will then be generated randomly about the star with the given velocity `v = sqrt((M_star+m_planet)/distance)`.
- `scale` refers to the screen:real ratio when drawing. Bigger numbers are more zoomed in, smaller numbers are more zoomed out.1
- `time_scale` refers to the passing of time. This, alongside the frame rate, affects the simulation's speed. All forces and velocities are multiplied by `dt * time_scale`2**1**: Use Z to zoom out, X to zoom in
**2**: Use A to slow down time, S to speed up time.
You can also use the arrow keys to move around.
## Running
As always, use```bash
cargo run
```To build and run.