/// <summary> /// Simple calculation of time base for the transfer assuming both are in circular orbit /// </summary> private void ComputeBaseTransferTime() { double xferOrbit = 0.5 * (shipRadius + moonRadius) / ge.GetPhysicalScale(); double planetMass = ge.GetMass(planet); timeHohmann = Mathd.PI * Mathd.Sqrt(xferOrbit * xferOrbit * xferOrbit / planetMass); }
private void ExecuteTransfer() { // Need to account for phasing, rotate ship forward to correct launch point and // rotate TLI vector. (This assumes circular orbit in the XY plane with the planet at the origin!) // Should set as a maneuver, but just jump there for demonstration code double transferTime = tflightFactor * lambertU.GetTMin(); float moonOmega = (float)System.Math.Sqrt(ge.GetMass(planet)) / Mathf.Sqrt(moonRadius * moonRadius * moonRadius); float shipThetaDeg = (float)(transferTime * moonOmega) * Mathf.Rad2Deg; Debug.LogFormat("t={0} theta={1} deg. omega={2} rad", transferTime, shipThetaDeg, moonOmega); // Inclination support. Recompute the transfer using inclination // @TODO: HACK XY only Vector3 shipPos = ge.GetPhysicsPosition(spaceship); Vector3 shipPosPhased = Quaternion.AngleAxis(shipThetaDeg, Vector3.forward) * shipPos; Vector3 shipVelPhased = Quaternion.AngleAxis(shipThetaDeg, Vector3.forward) * lambertU.GetTransferVelocity(); if (onRails) { TransferOnRails(transferTime, shipPosPhased, shipVelPhased, moonOmega); } else { Debug.LogFormat("tli NBody mode r={0} v={1}", shipPosPhased, shipVelPhased); ge.UpdatePositionAndVelocity(spaceship, shipPosPhased, shipVelPhased); } // remove placeholder ships/orbit visualizers ge.RemoveBody(shipExitSOI.gameObject); shipExitSOI.gameObject.SetActive(false); ge.RemoveBody(shipEnterSOI.gameObject); shipEnterSOI.gameObject.SetActive(false); SetOrbitDisplays(false); ge.SetEvolve(true); running = true; }