Let us say I have a grid of 1000 x 1000, and on that grid is drawn a circle, the circle could be anywhere.
If I then pick a random point from the grid with an x and y co-ordinate I can work out if the point is inside the circle by performing the following math,
xCoord = x co-ordinate;
yCoord = y co-ordinate;
xCenter = x co-ordinate of the center of the circle
yCenter = y co-ordinate of the center of the circle
radius = the circle's radius
((xCoord - xCenter) ^ 2 + (yCoord - yCenter) ^ 2) < (radius ^ 2)
If the radius ^ 2 is less than ((xCoord - xCenter) ^ 2 + (yCoord - yCenter) ^ 2) then it means that the co-ordinates were inside the circle.
I am struggling alot to wrap my head around this and cannot seem to work out how it works out that the co-ordinates were inside the circle.
Could someone please break this down for me and explain how it is worked out (what is going on in a logical manner so to speak)?
Sorry if my question is formatted wrong it is my first question on this site.
Thanks