I want to determine whether a point is inside a circle or not. So I do this :
(x - center_x)^2 + (y - center_y)^2 < radius^2
But my coordinates are double
and I think I should do it with epsilon, so is
fabs ((x - center_x)^2 + (y - center_y)^2 - radius^2 ) < EPS
better?
You don't need the epsilon when you're comparing using <
or >
, those are perfectly fine. You need it instead of ==
. In your case, you've just added a small amount to radius, which is probably undesirable.
Also note that ^
is not the same as pow(a, b)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With