0
$\begingroup$

Given a circle of radius $r$ located at $(x_c, y_c)$ and a rectangle defined by the points $(x_l, y_l), (x_l+w, y_l+h)$ is there a way to determine whether the the two overlap? The square's edges are parallel to the $x$ and $y$ axes.

I am thinking that overlap will occur if one of the rectangle's corners is contained in the circle or one of the circle's circumference points at ($n\frac{\pi}{2}, n=\{0,1,2,3\}$ radians) is contained in the rectangle. Is this true?

EDIT: One answer has pointed out a case not covered by the above which is resolved by also checking whether the center of the circle is contained.

Is there a method which doesn't involve checking all points on the circle's circumference?

  • 0
    Oh, do I feel foolish, @AD.! I have repaired the question.2012-11-02
  • 0
    Don't worry Richard it is a common typo. (Removed that comment of mine)2012-11-03

3 Answers 3