Alex Rivera | Logout

Equation for testing if a point is inside a circle

Asked 2009-01-26T20:07:26.487
408

If you have a circle with center (center_x, center_y) and radius radius, how do you test if a given point with coordinates (x, y) is inside the circle?

Edit
Report

1 Answer

13

Calculate the Distance

D = Math.Sqrt(Math.Pow(center_x - x, 2) + Math.Pow(center_y - y, 2))
return D <= radius

that's in C#...convert for use in python...

answered 2009-01-26T20:10:10.473

Your Answer