This test can be resumed using a single line test. Even if a good answer has already been sent, let me introduce mine.
Suppose that the first arc is A:(a0,a1) , and the second is B:(b0,b1) . I assume that the angle values are unique, that is, in the range [0°,360°[ , [0,2*pi[ or ]-pi,pi] (the range itself is not important, we will see why). I will take the range ]-pi,pi] as the range of all angles.
To explain the approach in detail, I first developed a test for intersecting intervals in R. Thus, here we have a1>=a0 and b1>=b0 . Following the same notation for real intervals, I calculate the following value:
S = (b0-a1)*(b1-a0)
If S>0 , two segments do not overlap, otherwise their intersection is not empty. It is really easy to see why this formula works. If S>0 , we have two cases:
b0>a1 means that b1>a0 , so there is no intersection: a0=<a1<b0=<b1 .
b1<a0 means that b0<b1 , so there is no intersection: b0=<b1<a0=<a1 .
So, we have one mathematical expression that works well in R.
Now I rotate it in a circular area ]-pi,pi] . The hypotheses a0<a1 and b0<b1 no longer true: for example, the arc can go from pi/2 to -pi/2 , this is the left semicircle. Therefore, I calculate the following value:
S = (b0-a1)*(b1-a0)*H(a1-a0)*H(b1-b0)
where H is a step function defined by H(x)=-1 if x<0 else H(x)=1
Again, if S>0 , there is no intersection between arcs A and B. There are 16 cases to study, and I will not do this here ... but they are easy to do on the sheet :).
Note : S value is not important, just condition signs. The beauty of this formula is that it does not depend on the range that you have adopted. Alternatively, you can rewrite it as a logical test:
T := (b0>a1)^(b1>a0)^(a1>=a0)^(b1>=b0)
where ^ is a logical XOR
EDIT
Alas, there is an obvious case of failure in this formula ... Therefore, I will fix it here. I understand that htere is a case where the intersection of two arcs can be two arcs, for example, when -pi<a0<b1<b0<a1<pi .
The solution to fix this is to introduce a second test: if the sum of the angles is above 2*pi , then the arcs intersect exactly.
Thus, the formula is equal to:
T := (a1+b1-a0-b0+2*pi*((b1<b0)+(a1<a0))<2*pi) | ((b0>a1)^(b1>a0)^(a1>=a0)^(b1>=b0))
Well, it’s less elegant than the previous one, but now it’s correct.