0
$\begingroup$

Diagram: https://i.imgur.com/uOqjSk8.jpg enter image description here

This is an easy problem if you compute the distance from the corner of the square at the center of the circle (just whether d is less-than-or-equal to r), but is it possible to determine from the point opposite that one without computing the distance from the circle's center.

The context is for image processing. I have the four outer corners of a bounding box but any algorithmic solution becomes complex when you need to compute which part of the bounding box a particular point is. However, I know that every point is inside the bounding box, so I'm wondering if it's possible to measure the distance from all four outer points and determine if a point would lie outside a circle based on its distance from those four corners.

$\endgroup$
2
  • 3
    $\begingroup$ You don't need the distance to the centre of the circle, you can compute the squared distance, which avoids the expensive square root function call. $\endgroup$
    – PM 2Ring
    Mar 23 '21 at 1:00
  • $\begingroup$ Do you know the angle between the dotted line and any one of the four sides of the square? $\endgroup$
    – YNK
    Mar 24 '21 at 9:39
0
$\begingroup$

For distances to two adjacent vertices: $$ d_1^2=(r-x)^2+(r-y)^2,\qquad d_2^2=(r+x)^2+(r-y)^2 $$ so one can find that, $$ 2(x^2+y^2) = d_1^2 + d_2^2 - \sqrt{(2r+d_1+d_2)(d_1+d_2-2r)(2r+d_1-d_2)(2r+d_2-d_1)} $$

From $2(x^2+y^2)>2r^2$, we find the critertion for the point to be out of the cirle: $$ d_1^2 + d_2^2 - \sqrt{(2r+d_1+d_2)(d_1+d_2-2r)(2r+d_1-d_2)(2r+d_2-d_1)} > 2r^2 $$

Or if you simplify: $$ d_1^4+d_2^4 +10r^4 > 6(d_1^2+d_2^2)r^2. $$

$\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.