# How to know if a point belongs more or less to a circle?

I know the formula to know if a point is inside, outside and on a circle : https://math.stackexchange.com/q/198769 This quote explains that we must compare d to r (please read the quote, it's only 5 lines).

But I just want to know if a point is ON a circle. Moreover, and that's the real problem : if a point is A BIT inside/outside a circle, I WANT to consider it as ON the circle.

How could I do that ? I tried to delimit d-r (ie. : the comparison) in a range. Example :

if(d-r > -100 && d-r < 100) { point is on the circle }

It works, with -100 and 100, for circles with a little radius (ie. : ALL the points that are a bit outside/inside the circle are considered as being on the circle).

But for circles for a big radius, only SOME points are considered as being on the circle (ie. : only some of the points that are a bit outside/inside the circle are considered as being on the circle)...

So I would want that ALL the points that are a bit outside/inside the circle are considered as being on the circle, independently of the circle's radius. How ?

• Perhaps the number that define the range (-100 or 100) can be dependent of the radius ? Perhaps I should multiply it by the radius. Edit : wrong idea. I tested, and even the very very very far points are detected as circle's ones... – JarsOfJam-Scheduler Apr 1 '17 at 15:30
• You mean relative to the radius. So try doing something like $|d-r| < \epsilon r$, where $\epsilon$ is a small number, which you can adjust according to needed precision. – samjoe Apr 1 '17 at 15:34
• The test would be : if(abs(d - r) < -ϵr) ? - edit thanks – JarsOfJam-Scheduler Apr 1 '17 at 15:37
• What are the minimal and maximal values you advise me for ϵ ? Because for values like 100, 50, 5 or even 1, all the points are considered as being on the circle, even very far ones – JarsOfJam-Scheduler Apr 1 '17 at 15:38
• That would always be false as $\epsilon r > 0$. You try something like if(abs(d - r) < ε r). And I do not have any experience with what you are working, so I don't have much idea sadly :) – samjoe Apr 1 '17 at 15:39

You must first define the maximal deviation =: $\varepsilon$ allowed.
if(abs(d-r)$\le \varepsilon)${Point can be considered as being on the circle} with r being the radius of the circle.