This commit is contained in:
Cat Flynn 2024-04-26 23:15:35 +01:00
parent 0ea2ae92ca
commit 63f0a91b79
1 changed files with 10 additions and 6 deletions

View File

@ -11,14 +11,14 @@ Easy enough, you take what you know about classical mechanics and impart some fo
Then you take little steps forward in time, applying some force due to gravity at every one.
You consider applying forces from air resistance too, but then remember you're a physicist, and think better of it.
Next, being in a simulation, you want to throw it a bit harder.
Like, superhuman hard - let's throw this thing into orbit.
Next, as you're in a simulation, you want to have some fun.
You decide to throw it a bit harder - let's put this thing into orbit!
You add a few zeroes to your initial throw and throw it straight ahead.
To your dismay once the ball gets more than a few kilometres away it does something funny.
To your dismay once the ball gets more than a few kilometres away it starts misbehaving.
It stops moving smoothly and instead begins to jitter.
Before long it's a complete mess, jumping from place to place and not really looking like it's been thrown at all.
Digging into your simulation, you find you've been using single-precision floats.
Digging into your simulation, you find you've been using single-precision floating points.
A rookie mistake!
You change them all to double-precision, and throw again.
This time, the ball sails smoothly away, and you watch it disappear over the virtual horizon.
@ -50,7 +50,7 @@ Kepler's laws make a simplification known as the two-body problem.
Kepler's laws of planetary motion describe the elliptical path of a object in a stable orbit.
This includes the paths of objects like the Moon and the International Space Station around the Earth, or the path of the Earth around the Sun.
More complex systems, such as Sun-Earth-Moon or the entire Solar System can be modelled as a composition of several two-body systems, rather than the _n_-body systems they really are.
This conveniently sidesteps the requirement to use approximate forces and therefore accumulate error over time.
This conveniently sidesteps the requirement to use approximate forces and therefore the accumulation of error over time.
The two body problem describes the motion of one body around another, or more precisely a common barycentre.
In the case of one massive and one tiny object, the barycentre is approximately in the same position as the centre of the larger object and can therefore be ignored.
In a two-body system, an orbit is perfectly stable and cyclical.
@ -89,12 +89,16 @@ Part of the determination of a planet's position as a function of time is the ca
![keplers-equation.png](keplers-equation.png)
In this equation, _E_ is the eccentric anomaly, the goal of the computation.
_M_ is the mean anomaly, which increases linearly over time.
The mean anomaly of Earth's orbit increases by pi every six months.
_e_ is the eccentricity of the orbit.
Having no closed-form solution for _E_, the equation must be solved with numerical methods.
A common choice is [Newton-Raphson](https://en.wikipedia.org/wiki/Newton%27s_method), a general-purpose root-finding algorithm which converges on successively better approximations through an arbitrary number of iterations.
It is straightforward to understand and implement, but it has some major flaws for real-time physics simulation.
For low-eccentricity orbits - those that are nearly circular - Newton-Raphson converges quickly in just a handful of iterations.
However, when presented with an eccentric orbit, such as those of the [Juno probe](https://science.nasa.gov/mission/juno/), NM takes exponentially more iterations to resolve to a high-accuracy solution.
However, when presented with an eccentric orbit, such as those of the [Juno probe](https://science.nasa.gov/mission/juno/), it takes exponentially more iterations to resolve to a high-accuracy solution.
With a lower number of iterations, the calculated value for _E_ is erratic and inaccurate, completely unsuitable for a stable simulation.
This presents a massive problem in a real-time system like a game.