5
$\begingroup$

I'm making a space exploration game. It will all take place within a single 2D plane (no inclination) and use patched-conics approximation so that a spacecraft is only gravitationally affected by one celestial body at a time. I have orbit simulations working perfectly given a set of parameters. These are the variables that orbits have in the program:

  • semi-major axis (meters)
  • eccentricity
  • argument of periapsis (radians)
  • whether the orbit is prograde or retrograde
  • standard gravitational parameter of the celestial body being orbited (m^3 s^-2)
  • the eccentric anomaly at t = 0 (radians)

And an object's current position is stored as its current eccentric anomaly in radians. Using these six parameters, I can define any elliptical orbit in the plane, and get the position and velocity of the object for any given time or eccentric anomaly.

What I can't do yet is make the orbit change based on the spacecraft's acceleration. Given a current eccentric anomaly, all six orbital parameters for an object, and a 2D vector for change in velocity, how can I compute the new orbital parameters?

$\endgroup$

2 Answers 2

5
$\begingroup$

So you know $\mu$ r and v, right? And you want to find a and e?

The Vis Viva equation tells us:
$v^2=\mu(2/r-1/a)$
$\mu/a=(2\mu/r)-v^2$
$a=\mu/((2\mu/r)-v^2)$
There's your expression for a.

I make mistakes so it's a good idea to check my algebra.

Now to find e. Denote specific angular momentum as h.
$h=\sqrt{a(1-e^2)\mu}$
$h^2=a(1-e^2)\mu$
$h^2/(a*\mu)=1-e^2$
$e=\sqrt{1-(h^2/(a*\mu))}$
Now $h=|\vec{h}|=|\vec{r}\times\vec{v}|$. Substitute this value into the above and you get e.

Again, it's a good idea to check my algebra.

$\endgroup$
1
  • $\begingroup$ Thank you, I did not know those equations existed. I'm learning a lot making this game :) However, a and e alone are not enough to define the orbit. I also need an argument of periapsis to define the 2D rotation of the orbit. $\endgroup$ Aug 17, 2017 at 19:56
2
$\begingroup$

If you already have your zenith angle $\gamma$, between velocity v and radius r, then

$$e^2 = 1-\frac{v^2r}{\mu} \ (2 - \frac{v^2r}{\mu}) \ sin^2(\gamma)$$

Derive this by substituting $|\mathbf{h}| = |\mathbf{r}||\mathbf{v}|sin(\gamma)$ and vis viva for $1/a$ into HopDavid's equation.

$\endgroup$
2
  • $\begingroup$ I've edited your answer and inserted the standard MathJax that is used in Stackexchange for equations etc. Take a look to make sure it still says the same thing, but I think it's unchanged. You can take a look here for a tutorial (which usually comes up if you search for "mathjax stackexchange") or read about MathJax elsewhere. $\endgroup$
    – uhoh
    Aug 18, 2017 at 3:48
  • 1
    $\begingroup$ UhOh, thank you for the edit and reference. I missed the requirement for leading and trailing $ signs in MathJax. - MBM $\endgroup$
    – MBM
    Aug 18, 2017 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.