/// <summary> /// if referenceInterval covers this interval completely, the result is 1 (equals 100%) /// if referenceInterval lies within this interval, the result is between 0 and 1 /// </summary> /// <param name="referenceInterval"></param> /// <returns></returns> public double GetPercentageOverlappingTo(AngleInterval referenceInterval) { if (referenceInterval.IsAngleWithin(From) && referenceInterval.IsAngleWithin(To)) { return(1.0); } if (!referenceInterval.IsOverlappingWith(this)) { return(0.0); } var fromInsideThis = IsAngleWithin(referenceInterval.From); var toInsideThis = IsAngleWithin(referenceInterval.To); Angle overlapping; if (fromInsideThis && toInsideThis) { overlapping = referenceInterval.AbsolutAngleValue; } else if (fromInsideThis) { overlapping = new AngleInterval(referenceInterval.From, To).AbsolutAngleValue; } else { overlapping = new AngleInterval(From, referenceInterval.To).AbsolutAngleValue; } return(overlapping / AbsolutAngleValue); }
public bool IsOverlappingWith(AngleInterval ai) { if (IsAngleWithin(ai.From)) { return(true); } if (IsAngleWithin(ai.To)) { return(true); } if (ai.IsAngleWithin(From)) { return(true); } if (ai.IsAngleWithin(To)) { return(true); } if (this == ai) { return(true); } return(false); }
public static Angle MinimalAngleBetween(Angle a1, Angle a2) { var interval = new AngleInterval(a1, a2); return((interval.AbsolutAngleValue.Value > 180) ? new Angle(360 - interval.AbsolutAngleValue.Value) : interval.AbsolutAngleValue); }