Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions MechJeb2/Maneuver/OperationCourseCorrection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ protected override List<ManeuverParameters> MakeNodesImpl(Orbit o, double ut, Me
ut = _timeSelector.ComputeManeuverTime(o, ut, target);
}

// the solver coasts from the burn to the end of the patch, the encounter
if (!(ut < o.EndUT))
// the solver coasts from the burn to the end of the patch, the encounter. A patch with no encounter (FINAL) has no
// end: KSP gives it one period, which bounds nothing
if (o.patchEndTransition != Orbit.PatchTransitionType.FINAL && !(ut < o.EndUT))
throw new OperationException(Localizer.Format("#MechJeb_approach_Exception3")); //the burn would be after the encounter with the target.

double dt = _timeSelector.TimeReference == TimeReference.COMPUTED ? double.NaN : 0;
Expand Down
4 changes: 3 additions & 1 deletion MechJeb2/OrbitalManeuverCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ public static (Vector3d dv, double dt1) DeltaVAndTimeForCourseCorrectionToCelest
double mu0 = o.referenceBody.gravParameter;
double mu1 = targetBody.gravParameter;
double soi = targetBody.sphereOfInfluence;
double tsoi = o.EndUT - ut;
// the coast from the burn: to the end of the patch, or, on a closed orbit with no encounter yet (FINAL, whose EndUT is one
// period after its start), one period from the burn
double tsoi = o.patchEndTransition == Orbit.PatchTransitionType.FINAL && o.eccentricity < 1 ? o.period : o.EndUT - ut;

(V3 r0, V3 v0) = o.RightHandedStateVectorsAtUT(ut);
(V3 r1, V3 v1) = target.RightHandedStateVectorsAtUT(ut);
Expand Down