Skip to content

JakeTaranov/orbitsim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A C++ with SFML program to simulate orbits of celestial bodies.

Input

The program reads in a json file with the attributes of N bodies in the form of:

{
  "bodies": [
    {
      "mass": 10000,
      "radius": 10,
      "pos_x": 600,
      "pos_y": 400,
      "vel_x": 0.5,
      "vel_y": 1.5,
      "drawline": true
    },
    {
      "mass": 10000,
      "radius": 10,
      "pos_x": 1000,
      "pos_y": 450,
      "vel_x": -0.5,
      "vel_y": -1.5,
      "drawline": true
    }
  ],
  "stay_in_bounds": true
}

Above is an example taken from stable_orbit.json

  • mass : mass of body n (int)
  • radius : radius of body n (int)
  • pos_x : initial x position of body n (int)
  • pos_y : initial y position of body n (int)
  • vel_x : initial x velocity of body n (int)
  • vel_y : initial y velocity of body n (int)
  • drawline : determines if the program will draw a trailing line of the body n's previous movement (bool)
  • stay_in_bounds : determines wether all the bodies will stay in the screen bounds by boncing off the edges (bool)

Examples

sim_1.mp4
sim_3.mp4

About

C++ Orbital Simulation of Celestial Bodies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages