Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How Can I see if 2 or more circels intersect or touching each other?

What I have tried:

When using rectangle and the upper left corner touch the lower right corner the circles aren't really touching. but intersect return true
Posted
Updated 20-Apr-21 1:21am
Comments
Richard MacCutchan 20-Apr-21 6:19am    
You need to find points inside each circle that are common.

Not really a programming question, more like geometry.
Quote:
How Can I see if 2 or more circels intersect or touching each other?

Each circle is inside a rectangle, if both rectangle don't touch, circles don't touch.
if rectangles touch, you need to calc the distance between circle centers, if that distance is less than sum of diameters, circles touch.
 
Share this answer
 
Comments
CPallini 20-Apr-21 6:42am    
5.
Patrice T 20-Apr-21 6:54am    
Thank you again
Don't even check the rectangle: get the value of the distance between circle centres and compare that to the sum of the diameters. If it's less then they overlap, if it's equal then they touch, if it's greater they are separate.

And it's easy to do: Pythagoras gives you the equation:
dist = √((Ax - Bx)2 + (Ay - By)2)
 
Share this answer
 
Comments
JR212 21-Apr-21 3:06am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900