We have a point (x,y) and some other points (xi,yi). How can we determine wich of (xi,yi) points are within a circle with center (x,y) and radius d (a given number) Thanks
+2
A:
Simple way.
Compute the distance from the point to the center of the circle. If less than radius , then its within the circle.
Andrew Keith
2009-10-26 21:49:13
you can optimize this. Ommit the SQRT for better performance.(xi-x)^2 + (yi-y)^2 <= d ^2
Andrew Keith
2009-10-26 21:53:54
+2
A:
If (xi - x)^2 + (yi - y)^2 is less than d^2, it's inside. If it equals d^2, it's on the circle. If it's greater than d^2, it's outside.
John at CashCommons
2009-10-26 21:50:09