How to find and print intersections of n given circles in O (n * log (n)) time?

I am looking for an algorithm O(n*logn)for finding and printing intersections of ngiven circles. Each circle is determined by its center and radius.

The O (n 2 ) algorithm consists in checking whether the distance between the centers is less or equal to the sum of the radii (from two compared circles). However, I am looking for a faster one!

A similar problem is the intersection of segments. I think that even my problem can be solved using the line-sweep algorithm , but I cannot figure out how to change the event queue in the case of circles.

Please pay attention to the following corner case. Black dots indicate event points (according to the permission of the user Sneftel below the intersection of the circles marked by arrows will not be printed)

Please take care of this in your solution

+4
source share
2 answers

This is the correct solution that I found based on a modification of the User Sneftel algorithm, which did not work for all cases.

enter image description here

Fig. 1: Imagine each circle as a bounded rectangle. Now, to use the scan line method by moving the scan line parallel to the y axis, we need two line segments to represent each circle of the y-range, as shown in Figure 2.

enter image description here

Having done this, the problem boils down to the following:

enter image description here

.
, AVL, , /// O (logn).
, , ( , , ). O (1) , .
: 4n ( n = > 2n = > 4n )
= O (4nlog (4n)) = O (nlogn)

+1

, (.. (x-r, y)), , . , , . , - , x. ( , , "" .)

" ".

+3

All Articles