The return journey from orbit around the moon to Earth is implemented in the OnrailsMoonToEarth scene. The solution uses a patched conic approach with the ship on rails to avoid the extreme sensitivity to initial conditions that would occur with a full three body solution (this can be simulated if GE mode is used).
The approach taken is similar in concept to the FreeReturnGeneric code. The return journey requires several steps:
- Locate the point when the ship will be opposite the Earth behind the moon and locate a ghost ship here. This calculation requires that the motion of the moon also be considered. This is the Trans Earth Injection (TEI) point.
- Locate a “ghost moon” at the time when the ship reaches TEI and place a ghost ship in orbit around this ghost moon at the point of TEI.
- Using an inspector provided velocity (as a fraction of the moon escape velocity) set this as the velocity on an OrbitPredictor attached to the TEI ghost ship. This forms the first “patch”, the hyperbola.
- Determine when the ghost ship reaches the Moon’s sphere of influence (SOI).
- Place a second ghost moon at the time when the ship will reach SOI. Place a second ghost ship at the SOI point on the escape hyperbola
- Set an OrbitPredictor on the SOI ship to predict an orbit around the Earth using the velocity relative to the Earth.
- Using this Earth orbit predictor report the perigee distance.
The result is a two patch sequence of orbits, used with a KeplerSequence component. The conceptual approach of an escape hyperbola and orbit to Earth are straight forward but the fact that the moon is moving during the hyperbolic escape requires some detailed adjustments.
The code that computes this transfer is less than 100 lines and can be found in the ComputeTransfer() method of the OnrailsMoonToEarth component. The comments provide additional details on how to use the API for the OrbitPredictor and OrbitUniversal elements to compute the necessary patch elements.