thombruce / verse

🚀 A universe in progress
Other
8 stars 0 forks source link

Orbits are not realtime #105

Closed thombruce closed 9 months ago

thombruce commented 9 months ago

I've done a few things to toy with scaling.... Key to this finding, I was messing with accelerating GameTime, however even when I was multiplying the game time by 4 billion, the planets would remain in their starting positions.

Following this, I have toyed with distances and masses and I'm pretty sure the issue is this...

The units I've used are not correct.

Either the MASS or the SEMI MAJOR AXIS is off by some factor in the equations I've been using, perhaps both.

It is very much as if the virtual distances are much greater than they ought to be, or the masses are much, much smaller than they ought to be.

I should review the code, the values I've provided and go back to the source that helped me set this up in the first place to see what I'm doing wrong exactly...

thombruce commented 9 months ago

Perhaps this gives us some idea what I'm doing wrong:

            Orbit {
                semi_major_axis: 4.0,
                eccentricity: 0.0,
                argument_of_periapsis: 0.0,
                initial_mean_anomaly: 0.0,
            },

Source: https://github.com/atbentley/bevy_mod_orbits/blob/main/examples/basic.rs

Notice the semi_major_axis is 4.0 whereas mine are... in the millions of kilometers.

Perhaps the unit I ought to be using is AU (Astronomical Units). This wouldn't line up exactly with the examples from that crate, but those are just examples. Earth's distance from the Sun in AU is around 1.0 - so very much on the correct scale, but the examples are off by 3.

thombruce commented 9 months ago

The problem was actually neither the masses nor the distances. It was an ORBITAL_PERIOD_SCALING_FACTOR constant leftover from earlier development.

Now that orbital period is tied to game time and the periods are true to life due to the accurate orbital values, this constant is no longer required.