Answer the question
In order to leave comments, you need to log in
How to correctly compare ranges of angles?
Two sectors are given: from angle A1 radians to angle A2 radians, and from angle B1 radians. up to B2 rad.
It is necessary to determine whether they have intersections.
How to solve it correctly-beautifully?
Something stalled with uncertainties when the angle can be set both as 7 * PI / 4
, and it is also as -PI / 4
.
Answer the question
In order to leave comments, you need to log in
One of the solutions. Let the sector A be described by an ordered pair {A1,A2}, i.e., A sector is the area obtained by going around the circle in a clockwise direction from point A1 to point A2.
1. Bring the values of all angles to the range from [0, 2pi).
2. If A1 > A2, then split the sector into two: S1 = [A1, 2pi) U [0, A2].
3. Using the set algebra and the algorithm of intersection of ordinary segments, one can find the intersection:
[A1, A2] ∩ [B1, B2] - the usual algorithm
( [A1, 2pi) U [0, A2] ) ∩ [B1, B2] = ( [B1, B2] ∩ [A1, 2pi) ) U ( [B1, B2] ∩ [0, A2] ) - for each of the intersections, the usual algorithm
( [A1, 2pi) U [0, A2] ) ∩ ( [B1 , 2pi) U [0, B2] ) - it is obvious that they intersect at least at the point 0
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question