/// <summary> /// Return the direction (clockwise / counterclockwise) with shortest rotation to given bearing /// </summary> /// <param name="value"></param> /// <param name="other"></param> /// <returns></returns> public static SpinDirection ShortestSpinDirectionTo(this Double value, Double other) { Double cw = Degrees.ClockwiseDifference(value, other); Double ccw = Degrees.CounterClockwiseDifference(value, other); return(cw < ccw ? SpinDirection.Clockwise : SpinDirection.CounterClockwise); }
/// <summary> /// Is this angle within 'degrees' of the 'from' value? /// </summary> /// <param name="value">this Double</param> /// <param name="from">Value to see if we are within range of</param> /// <param name="degrees">How many degrees slack?</param> /// <returns></returns> public static bool IsWithinDegressOf(this Double value, Double from, Double degrees) { Double diff = Math.Min(Degrees.ClockwiseDifference(value, from), Degrees.CounterClockwiseDifference(value, from));; return(diff <= degrees); }