# How to know if a point is inside a circle?

Having a circle with the centre $(x_c, y_c)$ with the radius $r$ how to know whether a point $(x_p, y_p)$ is inside the circle?

The distance between $\langle x_c,y_c\rangle$ and $\langle x_p,y_p\rangle$ is given by the Pythagorean theorem as The point $\langle x_p,y_p\rangle$ is inside the circle if $d, on the circle if $d=r$, and outside the circle if $d>r$. You can save yourself a little work by comparing $d^2$ with $r^2$ instead: the point is inside the circle if $d^2, on the circle if $d^2=r^2$, and outside the circle if $d^2>r^2$. Thus, you want to compare the number $(x_p-x_c)^2+(y_p-y_c)^2$ with $r^2$.