I am trying to solve simple task, but I am not finding any elegant solution.
I basically solving intersection of two circular sectors.
Each sector is given by 2 angles (from atan2 func) within (-pi, pi] range.
Each selector occupy maximum angle of 179.999. So it can be tell for every two angles where the circular sector is.
The return value should describe mutual intersection based on following:
value <1 if one angle is contained by second one (value represents how much space occupy percentually)
value >1 if first angle (the dotted one) is outside the other one, value represents how much of dotted angle is out of the other one
basic cases and some examples are on image bellow

the problem is that there are so many cases which should be handled and I am looking for some elegant way to solve it.
I can compare two angles only when they are on the right side of unit circle (cos>0) because on the left side, angle numerically bigger is graphically lower. I tried use some projection on the right half:
if(x not in <-pi/2, pi/2>)
{
c = getSign(x)*pi/2;
x = c - (x - c);
}
but there is a problem with sectors which occupy part of both halves of unit circle…
There are so many cases… Does somebody know how to solve this elegantly?
(I use c++, but any hint or pseudocode is fine)
You can do the following:
s_start,s_end) wheres_startis in (-pi,pi] ands_endin [s_start,s_start+pi).s0_start<s1_startnow we have only 3 cases (a, b1, b2):
a)
s1_start <= s0_end: intersection, s1_start inside s0b)
s1_start > s0_end:b1)
s0_start + 2*pi <= s1_end: intersection, (s0_start + 2*pi) inside s1b2)
s0_start + 2*pi > s1_end: no intersectionThus we get the following code: