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

121 Views Asked by At

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 ?

1

There are 1 best solutions below

0
On

You must first define the maximal deviation =: $\varepsilon$ allowed.

If we denote:

d := Distance from center

Then you would have the pseudo code:

if(abs(d-r)$\le \varepsilon)${Point can be considered as being on the circle} with r being the radius of the circle.