algorithm - Number of areas overlapped by exactly 3 circles -
i have task have number of circles. know 1 centre , radius. need find number of areas overlapped exactly 3 circles. tried solve knowing circles overlap when distance between centres shorter sum of radiuses, got me nowhere.
a sweep-line algorithm should job.
read sweep-line algorithms in general here, 1 particular (very important) algorithm here. overall structure of algorithm problem similar of bentley–ottmann algorithm. below details (not full description rather sketch; full description
take leftmost (min x) , rightmost (max x) points on each circle. sort these points x coordinate. put them priority queue.
run vertical sweep line along x axis. line contains collection of y coordinates of points intersects circles @ current x coordinate, sorted y.
once sweep line hits leftmost circle point, add the collection twice — once upper semicircle , once lower semicircle. once sweep line hits rightmost circle point, remove corresponding points collection. keep track of number of times each interval between 2 successive points covered circles. keep track of identity of these areas. whenever 2 points belong different circles appear next each other, calculate intersection points, , insert them point queue. every time sweep line hits intersection point, swap corresponding points in collection , adjust area identities , overlap counts.
it's easy visualise algorithm drawing circles on piece of paper, coloring each area differently, , moving ruler across drawing, noting how intersects circles , areas.
also google "line sweep algorithm" "circles".
Comments
Post a Comment