https://github.com/aluriak/gravastre
Qt, C++, computations, geometry, graviationnal simulation
https://github.com/aluriak/gravastre
cpp gravitational-simulations simulation
Last synced: about 1 year ago
JSON representation
Qt, C++, computations, geometry, graviationnal simulation
- Host: GitHub
- URL: https://github.com/aluriak/gravastre
- Owner: Aluriak
- Created: 2016-01-31T18:04:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-27T22:18:04.000Z (over 9 years ago)
- Last Synced: 2025-04-02T02:37:55.095Z (about 1 year ago)
- Topics: cpp, gravitational-simulations, simulation
- Language: C++
- Size: 86.9 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkd
Awesome Lists containing this project
README
# Gravastre
C++/Qt5 rewriting of [Gravastre-2.0](https://github.com/Aluriak/Gravastre-2.0).
## Main idea
Gravastre is a gravitationnal simulation where all agents (named Astres) interacts, no matter there distance or their mass.
The Qt interface allow user to see and play with the simulation during the computations.
## Usage
First, you will have to generate the builder Makefile:
make
(on some systems, `qmake-qt5` replace `qmake`. On failure, detect which is the correct typo
and modify the [Makefile](https://github.com/Aluriak/gravastre/blob/master/Makefile#L5) accordingly)
Then, go to build dir, build the project and launch it:
cd build
make
./gravastre
It's also possible to launch gravastre using a system defined in JSON file:
./gravastre mysystem.json
Take a look to `data/` directory for JSON file example.
## Interactions
Currently, some interactions are implemented:
- Mouse:
- left click: create a new unamed astre (hold to define an initial speed)
- right click: translation of the view (not properly working)
- mouse wheel: zoom
- Keyboard:
- i/e: decrease or increase mass of next created astres
- d: clear all universe
- a/u: decrease or increase the new astre initial speed sensitivity
- p: pausing simulation
- space: recenter to and track the selected astre
After playing, you may want to take a look to:
- main.cpp, where the initial system is defined
- converters.h, where some constants including collision presence, pixel per UA and simulation speed are defined
You can also define your own systems using the JSON format.
See [`data/`](https://github.com/Aluriak/gravastre/tree/master/data) and [usage](https://github.com/Aluriak/gravastre#usage).
## Features
- [X] complete and personalisable simulation
- [X] JSON configuration of systems
- [X] System: specify speed as double, not pair of double, and randomly place in orbit the subsystems
- [X] System,JSON: allow specifying an excentricity for the orbit, or any combination of valid parameters
- [X] zoom and translation in the world using the mouse
- [X] astre selection
- [X] config file for systems
- [ ] options: show trajectory of selected Astre as an ellipse
- [X] astre realistic radius
- [X] player handling
- [ ] token for replace astre when too far
- [ ] creation of an Astre trajectory knowing (all?) Astres
- [ ] print astre name when mouse over it (or its token)
- [ ] config file for constants (+option for using hard-coded ones)
- [ ] save systems
- [ ] provides GUI for generation of systems
- [ ] provides GUI for generating SPARQL queries and produce resulting systems
- [ ] informations about selected astre in a dedicated widget: name, mass, orbit trajectory, link to wikipedia
## Units
See the _converters.h_ header for units definitions and constants.
Units used by the Astre class are real units ; conversions to non real units is done dynamically,
when needed by the computations.
All positions and distances are given in [Astronomical Unit](https://en.wikipedia.org/wiki/Astronomical_unit).
The *reference*, optionally shown as a white rectangle, is placed at (0;0).
Speeds are in [meter per second](https://en.wikipedia.org/wiki/SI_base_unit).
### Adapting the simulation
Function to the system you want to seek, you could want to modify values found in the [options file](src/options.h).
By default, these values works well with a representation of the telluric planets of the solar system,
but for other systems like [TRAPPIST-1](TRAPPIST-1_system.json), you could want to tweak some values a little.
- PIXEL_PER_AU: number of pixel in one [astromical unit](https://en.wikipedia.org/wiki/Astronomical_unit). Increase it for a larger world.
- SIMULATION_SPEED: number of second passing between each computation step.
- COLLISION: if set to true, when two astres collides (this is based on their radius), the heavier absorbs the other. Its speed is modified in consequence.
- DEFAULT_RADIUS_BY_MASS_FACTOR: factor used for the computation of a radius from the mass. Useful to get radius giving an hint about mass. Increase it to get smaller radii.
- RADIUS_TO_PIXEL_FACTOR: in case radius (km) is deduced from input file, it will be converted using PIXEL_PER_AU and this value. 1=realistic (but invisible in most cases), more=bigger radii.
- ALWAYS_USE_DEFAULT_RADIUS: if set to true, ignore radius given in input file and use the *function to mass* radius.
- VIEW_ENGINE_TIME_UPDATE: number of millisecond between each engine update/computation step.