I have some circles and I know their X, Y, and r. I want to check if ANY of them collide with ANY other...
The way to check is easy:
r1+r2 < sqrt((x1-x2) 2 +(y1-y2)2)
but do I have to check all with all? It gives me O(n2) complexity, and I want to avoid that.
Try looking at KD-tree acc-struct. first you have to consider circles as squares way less complexity for computing intersection , than you put these squares in the modified KD-tree ,it will need some thinking but hopefully nothing too extreme ... Way kd-tree works is that it cancels out half of the possible matches based on some criteria for each tree level. Look it up on wiki. Good luck with your problem :)
You can divide your space into regions, like:
In 2. you can do many subdivisions, depending on your space size, also if to many circles are assigned to one box then subdivide it further.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With