给定同一个圆的两个圆段:A=[a1, a2] 和 B=[b1, b2],其中:
- a1, a2, b1, b2 值在 -inf 和 +inf 之间
- a1 <= a2 ; b1 <= b2
- a2-a1<=360; b2-b1<=360
我怎样才能知道这两个圆段是否重叠?(即如果它们至少在一点相交或接触)
例子:
A=[ -45°, 45°]; B=[ 10°, 20°] ==> overlap
A=[ -45°, 45°]; B=[ 90°, 180°] ==> no overlap
A=[ -45°, 45°]; B=[ 180°, 360°] ==> overlap
A=[ -405°, -315°]; B=[ 180°, 360°] ==> overlap
A=[-3600°, -3601°]; B=[ 3601°, 3602°] ==> overlap (touching counts as overlap)
A=[ 3600°, 3601°]; B=[-3601°,-3602°] ==> overlap (touching counts as overlap)
A=[ -1°, 1°]; B=[ 3602°, 3603°] ==> no overlap
这看起来像是一个看似简单的问题,但我无法理解它。我目前有一个解决方案的基本想法,如果每个部分超过 0°,则将其分成两部分,但我不确定这是否涵盖所有情况,我想知道是否有一个优雅的公式。