public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); if (!target.NormalTargetExists) { throw new OperationException("must select a target to match planes with."); } else if (o.referenceBody != target.TargetOrbit.referenceBody) { throw new OperationException("can only match planes with an object in the same sphere of influence."); } else if (timeSelector.timeReference == TimeReference.REL_ASCENDING) { if (!o.AscendingNodeExists(target.TargetOrbit)) { throw new OperationException("ascending node with target doesn't exist."); } } else { if (!o.DescendingNodeExists(target.TargetOrbit)) { throw new OperationException("descending node with target doesn't exist."); } } Vector3d dV = (timeSelector.timeReference == TimeReference.REL_ASCENDING) ? OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesAscending(o, target.TargetOrbit, UT, out UT): OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesDescending(o, target.TargetOrbit, UT, out UT); return new ManeuverParameters(dV, UT); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); if (o.referenceBody.Radius + newApA < o.Radius(UT)) { string burnAltitude = MuUtils.ToSI(o.Radius(UT) - o.referenceBody.Radius) + "m"; throw new OperationException("new apoapsis cannot be lower than the altitude of the burn (" + burnAltitude + ")"); } return new ManeuverParameters(OrbitalManeuverCalculator.DeltaVToChangeApoapsis(o, UT, newApA + o.referenceBody.Radius), UT); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { if (!target.NormalTargetExists) throw new OperationException("must select a target to match velocities with."); else if (o.referenceBody != target.TargetOrbit.referenceBody) throw new OperationException("target must be in the same sphere of influence."); double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); var dV = OrbitalManeuverCalculator.DeltaVToMatchVelocities(o, UT, target.TargetOrbit); return new ManeuverParameters(dV, UT); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); if (2*newSMA > o.Radius(UT) + o.referenceBody.sphereOfInfluence) { errorMessage = "Warning: new Semi-Major Axis is very large, and may result in a hyberbolic orbit"; } if(o.Radius(UT) > 2*newSMA) { throw new OperationException("cannot make Semi-Major Axis less than twice the burn altitude plus the radius of " + o.referenceBody.theName + "(" + MuUtils.ToSI(o.referenceBody.Radius, 3) + "m)"); } return new ManeuverParameters(OrbitalManeuverCalculator.DeltaVForSemiMajorAxis (o, UT, newSMA), UT); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); string burnAltitude = MuUtils.ToSI(o.Radius(UT) - o.referenceBody.Radius) + "m"; if (o.referenceBody.Radius + newPeA > o.Radius(UT)) { throw new OperationException("new periapsis cannot be higher than the altitude of the burn (" + burnAltitude + ")"); } else if (o.referenceBody.Radius + newApA < o.Radius(UT)) { throw new OperationException("new apoapsis cannot be lower than the altitude of the burn (" + burnAltitude + ")"); } else if (newPeA < -o.referenceBody.Radius) { throw new OperationException("new periapsis cannot be lower than minus the radius of " + o.referenceBody.theName + "(-" + MuUtils.ToSI(o.referenceBody.Radius, 3) + "m)"); } return new ManeuverParameters(OrbitalManeuverCalculator.DeltaVToEllipticize(o, UT, newPeA + o.referenceBody.Radius, newApA + o.referenceBody.Radius), UT); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); return new ManeuverParameters(OrbitalManeuverCalculator.DeltaVToChangeInclination(o, UT, newInc), UT); }
public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { GuiUtils.SimpleTextBox("New inclination:", newInc, "º"); timeSelector.DoChooseTimeGUI(); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); if (!target.NormalTargetExists) { throw new OperationException("must select a target to match planes with."); } else if (o.referenceBody != target.TargetOrbit.referenceBody) { throw new OperationException("can only match planes with an object in the same sphere of influence."); } var anExists = o.AscendingNodeExists(target.TargetOrbit); var dnExists = o.DescendingNodeExists(target.TargetOrbit); double anTime = 0; double dnTime = 0; var anDeltaV = anExists ? OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesAscending(o, target.TargetOrbit, UT, out anTime) : Vector3d.zero; var dnDeltaV = anExists ? OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesDescending(o, target.TargetOrbit, UT, out dnTime) : Vector3d.zero; Vector3d dV; if (timeSelector.timeReference == TimeReference.REL_ASCENDING) { if (!anExists) { throw new OperationException("ascending node with target doesn't exist."); } UT = anTime; dV = anDeltaV; } else if (timeSelector.timeReference == TimeReference.REL_DESCENDING) { if (!dnExists) { throw new OperationException("descending node with target doesn't exist."); } UT = dnTime; dV = dnDeltaV; } else if (timeSelector.timeReference == TimeReference.REL_NEAREST_AD) { if (!anExists && !dnExists) { throw new OperationException("neither ascending nor descending node with target exists."); } if (!dnExists || anTime <= dnTime) { UT = anTime; dV = anDeltaV; } else { UT = dnTime; dV = dnDeltaV; } } else if (timeSelector.timeReference == TimeReference.REL_HIGHEST_AD) { if (!anExists && !dnExists) { throw new OperationException("neither ascending nor descending node with target exists."); } if (!dnExists || anDeltaV.magnitude <= dnDeltaV.magnitude) { UT = anTime; dV = anDeltaV; } else { UT = dnTime; dV = dnDeltaV; } } else { throw new OperationException("wrong time reference."); } return(new ManeuverParameters(dV, UT)); }
public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { timeSelector.DoChooseTimeGUI(); }
protected override void LateUpdate() { if (shutdown) { return; } if (!HighLogic.LoadedSceneIsFlight || !FlightGlobals.ready) { return; } if (SCANcontroller.controller == null) { way = null; return; } if (!SCANcontroller.controller.mechJebTargetSelection) { way = null; return; } v = FlightGlobals.ActiveVessel; if (v == null) { SCANcontroller.controller.MechJebLoaded = false; way = null; return; } if (v.mainBody != SCANcontroller.controller.LandingTargetBody) { SCANcontroller.controller.LandingTargetBody = v.mainBody; } data = SCANUtil.getData(v.mainBody); if (data == null) { SCANcontroller.controller.MechJebLoaded = false; way = null; return; } if (v.FindPartModulesImplementing <MechJebCore>().Count <= 0) { SCANcontroller.controller.MechJebLoaded = false; way = null; return; } core = v.GetMasterMechJeb(); if (core == null) { SCANcontroller.controller.MechJebLoaded = false; way = null; return; } if (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX) { if (guidanceModule == null) { guidanceModule = (DisplayModule)core.GetComputerModule("MechJebModuleLandingGuidance"); } if (guidanceModule == null) { SCANcontroller.controller.MechJebLoaded = false; way = null; return; } if (!guidanceModule.unlockChecked) { return; } if (guidanceModule.hidden) { SCANcontroller.controller.MechJebLoaded = false; shutdown = true; way = null; return; } } target = core.target; if (target == null) { SCANcontroller.controller.MechJebLoaded = false; way = null; return; } if (!SCANcontroller.controller.MechJebLoaded) { SCANcontroller.controller.MechJebLoaded = true; RenderingManager.AddToPostDrawQueue(1, drawTarget); } if (SCANcontroller.controller.LandingTarget != null) { way = SCANcontroller.controller.LandingTarget; } if (SCANcontroller.controller.TargetSelecting) { way = null; selectingTarget = true; if (SCANcontroller.controller.TargetSelectingActive) { selectingInMap = true; } else { selectingInMap = false; } coords = SCANcontroller.controller.LandingTargetCoords; return; } else if (selectingTarget) { selectingTarget = false; if (selectingInMap) { selectingInMap = false; coords = SCANcontroller.controller.LandingTargetCoords; way = new SCANwaypoint(coords.y, coords.x, siteName); target.SetPositionTarget(SCANcontroller.controller.LandingTargetBody, way.Latitude, way.Longitude); } } selectingInMap = false; selectingTarget = false; if (target.Target == null) { way = null; return; } if (target.targetBody != v.mainBody) { way = null; return; } if (!(target.Target is PositionTarget)) { way = null; return; } coords.x = target.targetLongitude; coords.y = target.targetLatitude; if (way != null) { if (!SCANUtil.ApproxEq(coords.x, way.Longitude) || !SCANUtil.ApproxEq(coords.y, way.Latitude)) { way = new SCANwaypoint(coords.y, coords.x, siteName); SCANcontroller.controller.LandingTarget = way; data.addToWaypoints(); } } else { way = new SCANwaypoint(coords.y, coords.x, siteName); SCANcontroller.controller.LandingTarget = way; data.addToWaypoints(); } }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); if (!target.NormalTargetExists) { throw new OperationException("must select a target to match planes with."); } else if (o.referenceBody != target.TargetOrbit.referenceBody) { throw new OperationException("can only match planes with an object in the same sphere of influence."); } var anExists = o.AscendingNodeExists(target.TargetOrbit); var dnExists = o.DescendingNodeExists(target.TargetOrbit); double anTime = 0; double dnTime = 0; var anDeltaV = anExists ? OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesAscending(o, target.TargetOrbit, UT, out anTime) : Vector3d.zero; var dnDeltaV = anExists ? OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesDescending(o, target.TargetOrbit, UT, out dnTime) : Vector3d.zero; Vector3d dV; if(timeSelector.timeReference == TimeReference.REL_ASCENDING) { if(!anExists) { throw new OperationException("ascending node with target doesn't exist."); } UT = anTime; dV = anDeltaV; } else if(timeSelector.timeReference == TimeReference.REL_DESCENDING) { if(!dnExists) { throw new OperationException("descending node with target doesn't exist."); } UT = dnTime; dV = dnDeltaV; } else if(timeSelector.timeReference == TimeReference.REL_NEAREST_AD) { if(!anExists && !dnExists) { throw new OperationException("neither ascending nor descending node with target exists."); } if(!dnExists || anTime <= dnTime) { UT = anTime; dV = anDeltaV; } else { UT = dnTime; dV = dnDeltaV; } } else if(timeSelector.timeReference == TimeReference.REL_HIGHEST_AD) { if(!anExists && !dnExists) { throw new OperationException("neither ascending nor descending node with target exists."); } if(!dnExists || anDeltaV.magnitude <= dnDeltaV.magnitude) { UT = anTime; dV = anDeltaV; } else { UT = dnTime; dV = dnDeltaV; } } else { throw new OperationException("wrong time reference."); } return new ManeuverParameters(dV, UT); }
public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { GuiUtils.SimpleTextBox("New periapsis:", newPeA, "km"); GuiUtils.SimpleTextBox("New apoapsis:", newApA, "km"); timeSelector.DoChooseTimeGUI(); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); if (2 * newSMA > o.Radius(UT) + o.referenceBody.sphereOfInfluence) { errorMessage = "Warning: new Semi-Major Axis is very large, and may result in a hyberbolic orbit"; } if (o.Radius(UT) > 2 * newSMA) { throw new OperationException("cannot make Semi-Major Axis less than twice the burn altitude plus the radius of " + o.referenceBody.theName + "(" + MuUtils.ToSI(o.referenceBody.Radius, 3) + "m)"); } return(new ManeuverParameters(OrbitalManeuverCalculator.DeltaVForSemiMajorAxis(o, UT, newSMA), UT)); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { if (!target.NormalTargetExists) { throw new OperationException("must select a target to intercept."); } if (o.referenceBody != target.TargetOrbit.referenceBody) { throw new OperationException("target must be in the same sphere of influence."); } double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); var dV = OrbitalManeuverCalculator.DeltaVToInterceptAtTime(o, UT, target.TargetOrbit, UT + interceptInterval); return(new ManeuverParameters(dV, UT)); }
public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { GuiUtils.SimpleTextBox("Time after burn to intercept target:", interceptInterval); timeSelector.DoChooseTimeGUI(); }
public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { GuiUtils.SimpleTextBox("Time after burn to intercept target:", interceptInterval); timeSelector.DoChooseTimeGUI(); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); if (!target.NormalTargetExists) { throw new OperationException("must select a target to match planes with."); } else if (o.referenceBody != target.TargetOrbit.referenceBody) { throw new OperationException("can only match planes with an object in the same sphere of influence."); } else if (timeSelector.timeReference == TimeReference.REL_ASCENDING) { if (!o.AscendingNodeExists(target.TargetOrbit)) { throw new OperationException("ascending node with target doesn't exist."); } } else { if (!o.DescendingNodeExists(target.TargetOrbit)) { throw new OperationException("descending node with target doesn't exist."); } } Vector3d dV = (timeSelector.timeReference == TimeReference.REL_ASCENDING) ? OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesAscending(o, target.TargetOrbit, UT, out UT): OrbitalManeuverCalculator.DeltaVAndTimeToMatchPlanesDescending(o, target.TargetOrbit, UT, out UT); return(new ManeuverParameters(dV, UT)); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); if (o.referenceBody.Radius + newApA < o.Radius(UT)) { string burnAltitude = MuUtils.ToSI(o.Radius(UT) - o.referenceBody.Radius) + "m"; throw new OperationException("new apoapsis cannot be lower than the altitude of the burn (" + burnAltitude + ")"); } return(new ManeuverParameters(OrbitalManeuverCalculator.DeltaVToChangeApoapsis(o, UT, newApA + o.referenceBody.Radius), UT)); }
public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { GuiUtils.SimpleTextBox("New Semi-Major Axis:", newSMA, "km"); timeSelector.DoChooseTimeGUI(); }
public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { GuiUtils.SimpleTextBox("New inclination:", newInc, "º"); timeSelector.DoChooseTimeGUI(); }
public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { GuiUtils.SimpleTextBox("New periapsis:", newPeA, "km"); timeSelector.DoChooseTimeGUI(); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); return(new ManeuverParameters(OrbitalManeuverCalculator.DeltaVToCircularize(o, UT), UT)); }
public override ManeuverParameters MakeNodeImpl(Orbit o, double universalTime, MechJebModuleTargetController target) { double UT = timeSelector.ComputeManeuverTime(o, universalTime, target); string burnAltitude = MuUtils.ToSI(o.Radius(UT) - o.referenceBody.Radius) + "m"; if (o.referenceBody.Radius + newPeA > o.Radius(UT)) { throw new OperationException("new periapsis cannot be higher than the altitude of the burn (" + burnAltitude + ")"); } else if (o.referenceBody.Radius + newApA < o.Radius(UT)) { throw new OperationException("new apoapsis cannot be lower than the altitude of the burn (" + burnAltitude + ")"); } else if (newPeA < -o.referenceBody.Radius) { throw new OperationException("new periapsis cannot be lower than minus the radius of " + o.referenceBody.displayName + "(-" + MuUtils.ToSI(o.referenceBody.Radius, 3) + "m)"); } return(new ManeuverParameters(OrbitalManeuverCalculator.DeltaVToEllipticize(o, UT, newPeA + o.referenceBody.Radius, newApA + o.referenceBody.Radius), UT)); }
public override void DoParametersGUI(Orbit o, double universalTime, MechJebModuleTargetController target) { timeSelector.DoChooseTimeGUI(); }