0

I'm procedurally generating 2D solar systems, and I want planets to have varying, persistent orbits. I'm stuck trying to figure out how I can calculate the current angle relative to the body it's orbiting at any given time, which should be the same for everyone regardless of their local time. If I'm using a seeded Math.random to calculate these generated variables, how might this be done?

Spektre
  • 49,595
  • 11
  • 110
  • 380
Suffick
  • 641
  • 1
  • 6
  • 15

1 Answers1

1
  1. implement simulation of solar system according to Kepler's laws

    that is easy in 3D and even easier in 2D (no inclinations) look here

    just use some globally synchronized time as parameter for this. I mean with this that all players/observers should have the time synchronized between each other)

  2. use seeded pseudo randoms for orbital elements parameters

    like a,e,i,o,O of coarse add some ranges for them for example:

    • a - major semi axis should be in range <0.01,200> [AU] so

      a=(0.01+(200.0-0.01)*Random())*AU;`
      

      where AU is astronomical unit constant, and Random gives pseudo random number <0.0,1.0>

    • e eccentricity should be in range <0.00,1.00> [-]

    • i,o,O are angles so <0,2.0*PI> [rad]

    similarly you can add all supported rotation periods. Beware that mean orbital period around central object is dependent on its distance from it and masses ratio (for game you can ignore this). Also there are empiric equations for planet mass/size/distance ratios observed from solar system.

[Notes]


In 2D is no inclination so you can omit the inclination and node angles so only the periaxis angle remains.
All rotations periods have also start angle in some defined timed called epoch.
All parameters can be changing in time (but for game is this not relevant unless you want to measure things in it...)

Spektre
  • 49,595
  • 11
  • 110
  • 380