Given the coordiantes of the center and the radius of a circle, how can I determine if a point $(x,y)$ touches the circumference or not?

356 Views Asked by At

So let's say that I have a standard $(x, y)$ coordinates system, the center of a circle $(0,1)$ and the radius $(1)$. How can I determine that whether the point $(0,0)$ touches the circumference or not?

I don't need to determine if the point is inside or outside the circumference but my problem is related with its touching the circumference of the following circle.

1

There are 1 best solutions below

0
On BEST ANSWER

The general equation for the circle is $(x-c_x)^2 + (y-c_y)^2 = r^2$, where $(c_x,c_y)$ is the center and $r$ is the radius. A point $(x,y)$ lies on the circle (the disk's boundary) if it satisfies the above equation. If instead: $(x-c_x)^2 + (y-c_y)^2 < r^2$ then it is inside the disk, and similarly it is outside for $>$.

Edit: This can be extended to arbitrary high dimensions, let $\vec{c}\in \mathbb{R}^n$ be the center of the $n$ dimensional hypersphere, and $r$ be its radius. Then a point $\vec{v}\in \mathbb{R}^n$ lies on its surface if $|\vec{v}-\vec{c}|^2 = r^2$, where $|\vec{a}| = \sqrt{\sum_{i=1}^{n}{a_i^2}}$ is the Euclidean norm. It is inside the hyperball for $<$ and outside for $>$.