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?