public override void Execute(SafeSharedObjects shared) { double ang2 = GetDouble(PopValueAssert(shared)); double ang1 = GetDouble(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); double result = KOSMath.DegreeFix(ang2 - ang1, -180); ReturnValue = result; }
/// <summary> /// Fix the strange too-large or too-small angle degrees that are sometimes /// returned by KSP, normalizing them into a constrained 360 degree range. /// </summary> /// <param name="inAngle">input angle in degrees</param> /// <param name="rangeStart"> /// Bottom of 360 degree range to normalize to. /// ( 0 means the range [0..360]), while -180 means [-180,180] ) /// </param> /// <returns>the same angle, normalized to the range given.</returns> public static double DegreeFix(double inAngle, double rangeStart) { // Use the kOS.Safe implementation to avoid duplicated code return(KOSMath.DegreeFix(inAngle, rangeStart)); }