0
$\begingroup$

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 ?

$\endgroup$
  • $\begingroup$ 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... $\endgroup$ – JarsOfJam-Scheduler Apr 1 '17 at 15:30
  • $\begingroup$ 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. $\endgroup$ – samjoe Apr 1 '17 at 15:34
  • $\begingroup$ The test would be : if(abs(d - r) < -ϵr) ? - edit thanks $\endgroup$ – JarsOfJam-Scheduler Apr 1 '17 at 15:37
  • $\begingroup$ 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 $\endgroup$ – JarsOfJam-Scheduler Apr 1 '17 at 15:38
  • $\begingroup$ 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 :) $\endgroup$ – samjoe Apr 1 '17 at 15:39
0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.