Picture a circle. Now divide the circle vertically and horizontally into four regions. Take the top left region. If you drew a box around it, you’d have a box with a rounded corner heading east.
Given an X and Y coordinate in that box of that single top left region, how can I tell whether a point is to the left of the circle’s line, or to the right?
You can solve the problem by realizing:
rof that pointSo you can solve the problem, given the center of the circle at
(a,b)and knowing the dimensions of the square box having sider…any given point(x,y)inside the box is also inside the circle if and only if:Such a point resides outside or exactly on the circle if and only if this condition is false.
As Derek E. suggests in a comment, when implementing this solution it’s better to compare the squared distance to avoid the approximations of the sqrt function.