How does a change in velocity affect the properties of an orbit in a 2D plane?

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
• 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?

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)$

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.

• 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. – Iamsodarncool Aug 17 '17 at 19:56

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.

• 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. – uhoh Aug 18 '17 at 3:48
• UhOh, thank you for the edit and reference. I missed the requirement for leading and trailing \$ signs in MathJax. - MBM – MBM Aug 18 '17 at 17:23