# How to calculate apoapsis of sub-orbital trajectory?

I have made a RK4 simulator for launching a cannonball from a tower. Which has the state variables:

• Position vector r
• Velocity vector v
• Mass of planet M

To simplify it, working in only 2 dimensions (orbits on equatorial plane) and ignoring the cannonball mass since M is much greater then mass of cannonball. The cannonball also moves ballistically (no air drag etc).

The output from the simulator firing 100km above surface (Orange is the planet, Blue is 60 degree launch angle, Yellow is 30 degree launch angle): A closer look at some trajectories (Green: 60, Yellow: 45, Orange: 30, Blue: 0) I want to be able to calculate the apoapsis of the orbit, what is the formula given v, r and M?

• Long story short: ignore the planet surface, calculate as any other orbit. Unless you account for gravitational field nonuniformities due to Earth not being perfectly spherical, approximating it with a point mass is absolutely sufficient. – SF. Mar 17 '17 at 16:21

First calculate the semi-major axis $a$ where $\mu$ is standard gravitational parameter of the planet that in orbit around: $$E=\frac{v^2}{2}-\frac{\mu}{r}$$ $$a = -\frac{\mu}{2E}$$
Then with the eccentricity vector: $$e = {\left |v \right |^2 r \over {\mu}} - {(r \cdot v ) v \over{\mu}} - {r\over{\left|r\right|}}$$
Can now calculate: $$r_p=a(1-\left|e\right|)$$ $$r_a=a(1+\left|e\right|)$$
• $r_a\,\!$ is the radius at apoapsis (i.e., the farthest distance of the orbit to the center of mass of the system, which is a focus of the ellipse).
• $r_p\,\!$ is the radius at periapsis (the closest distance).