overlaps360 method
Returns true if this angle range overlaps range2
's angle range
(exclusive of the endpoints).
The ranges are projected onto the 0-360 degree range.
Implementation
bool overlaps360(AngleRange range2) {
if (overlaps(range2)) return true;
// No direct overlap... check if the projections overlap
final list1 = <AngleRange>[];
final min360 = minValue.angle360;
var max360 = maxValue.angle360;
if (max360 < min360) {
max360 = max360 + Angle(rad: twoPi) as Angle;
list1
..add(AngleRange(min360, Angle(rad: twoPi)))
..add(AngleRange(Angle(rad: 0), max360));
} else {
list1.add(AngleRange(min360, max360));
}
final list2 = <AngleRange>[];
final min360two = range2.minValue.angle360;
var max360two = range2.maxValue.angle360;
if (max360two < min360two) {
max360two = max360two + Angle(rad: twoPi) as Angle;
list2
..add(AngleRange(min360two, Angle(rad: twoPi)))
..add(AngleRange(Angle(rad: 0), max360two));
} else {
list2.add(AngleRange(min360two, max360two));
}
for (final range1 in list1) {
for (final range2 in list2) {
if (range1.overlaps(range2)) return true;
}
}
return false;
}