Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Checking If Coordinates Are Within Circle [duplicate]

Possible Duplicate:
How can I make Turtle recognize a circle?

enter image description hereI have a function that draws a few circles and I am going to place dots inside them. Depending if the dot falls within the circle, depends on wether the colour will change or not.

The biggest issue I am finding is how to check whether or not the dot is within the circle. Does anyone have any idea how to calculate coordinates within a circle or is their a method which can check coordinates against the circle?

like image 798
MichaelH Avatar asked Sep 04 '12 10:09

MichaelH


1 Answers

For a circle with center (x,y) and radius r, a point (x1, y1) is within the circle if

(x1-x)² + (y1-y)² <= r²
like image 70
gefei Avatar answered Jan 04 '23 10:01

gefei