Finding all intersecting circles of one circle.

70 Views Asked by At

I have one circle $C_0(x_0,y_0,R_0)$ in a plane (which moves around here and there). There are many other circles on the same plane $C_1(x_1,y_1,R_1),C_2(x_2,y_2,R_2).....,C_n(x_n,y_n,R_n)$ where ${n\to billion}$ (which are kind of fixed on the plane).

I know that if two circles intersects each other, satisfy this

$(R_0-R_1)^{2} <=(x_0-x_1)^{2} + (y_0-y_1)^{2} <=(R_0+R_1)^{2}$

But processing n no of circles with one circle will take huge amount of time.

I am looking for some mathematical formula or concept which finds all those circles which intersects with circle $C_0$.

Once I have some formula or concept, I have to implement that into a computer program.

Any help or suggestions would be highly appreciated.

1

There are 1 best solutions below

1
On BEST ANSWER

Divide your plane into say 1 million squares (1000 by 1000 grid).

Each of your fixed circles will fit inside some square of squares (a simplification, but makes calculations easier). Create for each square a list of the circles that may pass through it. This is a little tedious, but you only have to do it once.

Now, as your circle moves, you only need to identify the square of squares that it lies within. This will give you a large list of all possible circles that may intersect your circle. Test these.

This process will simply reduce the number of tests that need to be made, but should reduce your calculation time considerably.