Skip to content

mwja/rust-galaxies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

    Path tracing Zoomed in

Config

The default configuration file looks like:

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_scale2

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

cargo run

To build and run.

About

Simple galaxy/star simulation engine in Rust

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages