Skip to content

Commit

Permalink
add negative apoapsis hyperbolic orbits
Browse files Browse the repository at this point in the history
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
  • Loading branch information
lamont-granquist committed Jul 17, 2017
1 parent 03a62a1 commit fa4d544
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions MechJeb2/MechJebModuleAscentPEG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class MechJebModuleAscentPEG : MechJebModuleAscentBase
[Persistent(pass = (int)(Pass.Type))]
public EditableDoubleMult pitchEndTime = new EditableDoubleMult(55);
[Persistent(pass = (int)(Pass.Global))]
public EditableDoubleMult desiredApoapsis = new EditableDoubleMult(-1, 1000);
public EditableDoubleMult desiredApoapsis = new EditableDoubleMult(0, 1000);
[Persistent(pass = (int)(Pass.Type))]
public EditableDoubleMult terminalGuidanceSecs = new EditableDoubleMult(10);
[Persistent(pass = (int)(Pass.Type))]
Expand Down Expand Up @@ -338,10 +338,10 @@ void UpdateStageStats()
}

private double smaT() {
if ( desiredApoapsis > autopilot.desiredOrbitAltitude )
return (autopilot.desiredOrbitAltitude + 2 * mainBody.Radius + desiredApoapsis) / 2;
else
if ( desiredApoapsis >= 0 && desiredApoapsis < autopilot.desiredOrbitAltitude )
return autopilot.desiredOrbitAltitude + mainBody.Radius;
else
return (autopilot.desiredOrbitAltitude + 2 * mainBody.Radius + desiredApoapsis) / 2;
}

private void UpdateRocketStats() {
Expand Down
2 changes: 1 addition & 1 deletion MechJeb2/MechJebModuleAscentPEGMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override void WindowGUI(int windowID)

GuiUtils.SimpleTextBox("Target Periapsis:", autopilot.desiredOrbitAltitude, "km");
GuiUtils.SimpleTextBox("Target Apoapsis:", path.desiredApoapsis, "km");
if ( path.desiredApoapsis < autopilot.desiredOrbitAltitude )
if ( path.desiredApoapsis >= 0 && path.desiredApoapsis < autopilot.desiredOrbitAltitude )
{
GUIStyle s = new GUIStyle(GUI.skin.label);
s.normal.textColor = Color.yellow;
Expand Down

0 comments on commit fa4d544

Please sign in to comment.