Equation for testing if a point is inside a circle

algorithmgeometrylanguage-agnostic

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?

Best Answer

In general, x and y must satisfy (x - center_x)² + (y - center_y)² < radius².

Please note that points that satisfy the above equation with < replaced by == are considered the points on the circle, and the points that satisfy the above equation with < replaced by > are considered the outside the circle.