// sma is only used for the initial guess but it is the responsibility of the caller public void flightangle5constraint(double rT, double vT, double inc, double gamma, double LAN, double sma, bool omitCoast, bool targetInc, bool targetLAN) { if (status == PVGStatus.ENABLED) { return; } bool doupdate = false; if (rT != old_rT || vT != old_vT || gamma != old_gamma) { doupdate = true; } // if we are tracking a target LAN, don't reset if (LAN != old_LAN && !targetLAN) { doupdate = true; } // if we are tracking a target inc, don't reset if (inc != old_inc && !targetInc) { doupdate = true; } if (p != null && p.bctype != BCType.FLIGHTANGLE5) { doupdate = true; } if (p == null || doupdate) { if (p != null) { p.KillThread(); } Debug.Log("[MechJeb] MechJebModuleGuidanceController: setting up flightangle5constraint, rT: " + rT + " vT:" + vT + " inc:" + inc + " gamma:" + gamma + " LAN:" + LAN + " sma: " + sma); PontryaginLaunch solver = NewPontryaginForLaunch(inc, sma); solver.omitCoast = omitCoast; solver.flightangle5constraint(rT, vT, gamma * UtilMath.Deg2Rad, inc * UtilMath.Deg2Rad, LAN * UtilMath.Deg2Rad); p = solver; } old_rT = rT; old_vT = vT; old_inc = inc; old_gamma = gamma; old_LAN = LAN; }
public void TargetPeInsertMatchOrbitPlane(double PeA, double ApA, Orbit o, bool omitCoast) { if (status == PVGStatus.ENABLED) { return; } bool doupdate = false; double v0m, r0m, sma; ConvertToRadVel(PeA, ApA, out r0m, out v0m, out sma); if (r0m != old_r0m || v0m != old_v0m) { doupdate = true; } if (p == null || doupdate) { if (p != null) { p.KillThread(); } lambdaDot = Vector3d.zero; double desiredHeading = OrbitalManeuverCalculator.HeadingForInclination(o.inclination, vesselState.latitude); Vector3d desiredHeadingVector = Math.Sin(desiredHeading * UtilMath.Deg2Rad) * vesselState.east + Math.Cos(desiredHeading * UtilMath.Deg2Rad) * vesselState.north; Vector3d desiredThrustVector = Math.Cos(45 * UtilMath.Deg2Rad) * desiredHeadingVector + Math.Sin(45 * UtilMath.Deg2Rad) * vesselState.up; /* 45 pitch guess */ lambda = desiredThrustVector; PontryaginLaunch solver = new PontryaginLaunch(core: core, mu: mainBody.gravParameter, r0: vesselState.orbitalPosition, v0: vesselState.orbitalVelocity, pv0: lambda.normalized, pr0: Vector3d.zero, dV: v0m); solver.omitCoast = omitCoast; Vector3d pos, vel; o.GetOrbitalStateVectorsAtUT(vesselState.time, out pos, out vel); Vector3d h = Vector3d.Cross(pos.xzy, vel.xzy); double hTm = v0m * r0m; // FIXME: gamma solver.flightangle5constraint(r0m, v0m, 0, h.normalized * hTm); p = solver; Debug.Log("created TargetPeInsertMatchOrbitPlane solver"); } old_v0m = v0m; old_r0m = r0m; }
// sma is only used for the initial guess but it is the responsibility of the caller public void flightangle5constraint(double rT, double vT, double inc, double gamma, double LAN, double sma, bool omitCoast, bool currentInc) { if (status == PVGStatus.ENABLED) { return; } bool doupdate = false; if (rT != old_rT || vT != old_vT || gamma != old_gamma || LAN != old_LAN) { doupdate = true; } // avoid slight drift in the current inclination from resetting guidance constantly if (inc != old_inc && !currentInc) { doupdate = true; } if (p == null || doupdate) { if (p != null) { p.KillThread(); } Debug.Log("[MechJeb] MechJebModuleGuidanceController: setting up flightangle5constraint, rT: " + rT + " vT:" + vT + " inc:" + inc + " gamma:" + gamma + " LAN:" + LAN + " sma: " + sma); PontryaginLaunch solver = NewPontryaginForLaunch(inc, sma); solver.omitCoast = omitCoast; solver.flightangle5constraint(rT, vT, gamma * UtilMath.Deg2Rad, inc * UtilMath.Deg2Rad, LAN * UtilMath.Deg2Rad); p = solver; } old_rT = rT; old_vT = vT; old_inc = inc; old_gamma = gamma; old_LAN = LAN; }