Given a set of sectors (startAngle, stopAngle) on the same circle (0-2pi), I want to reduce the set so that all sectors that overlap/intersect, are merged. Preferably, in the process, I don't want to split any sector that spans over 360deg/2pi.
Using the intersect-operation of "check if two segments on the same circle overlap / intersect" it seems straight forward to just compare each sector in a pre-sorted set (lesser startAngle first) and merge any compared two sectors that intersect. However, that approach only seem to work if sectors that span over 360deg/2pi are first split in two.
Can anyone help with a more elegant solution that does not involve splitting any sectors? (Pseudo-code, Java or Ada preferably)