1
$\begingroup$

I have a circle of center $(x_c, y_c)$ and radius $r$, and a square of center $(x_s, y_s)$ and width $w$:

enter image description here

The square will always be oriented such that its sides are parallel to the x,y axis of a system such as the one shown in the figure, centered at $(x_c, y_c)$.

How can I obtain the area of the square that is within the limit defined by the radius of the circle (ie: the red portion)? This portion will be 1 if the entire square is inside the radius $r$, and zero if the entire square is outside.

$\endgroup$
  • 1
    $\begingroup$ What orientation is the square to the circle? The will also be a required piece of information. Or equivalently we need one (just one) of the corners. $\endgroup$ – fleablood Sep 5 '17 at 15:42
  • $\begingroup$ Sorry, I forgot to mention that. I'll add it to my question. $\endgroup$ – Gabriel Sep 5 '17 at 15:42
  • $\begingroup$ Do you need an exact or approximate evaluation ? $\endgroup$ – Yves Daoust Sep 5 '17 at 15:47
  • $\begingroup$ @fleablood: assuming an axis-aligned square causes no loss of generality. $\endgroup$ – Yves Daoust Sep 5 '17 at 15:48
  • 1
    $\begingroup$ There are tons of special case for the value. see this answer for details. $\endgroup$ – achille hui Sep 5 '17 at 16:14
1
$\begingroup$

Hint:

You can derive the area inside the square from the area inside an infinite "corner" ($x\ge x_c,y\ge y_c$), by summing algebraically contributions from the four vertices of the square.

The area covered by a corner is obtained by integrating $\sqrt{1-x^2}-y_c$ from $x_c$ to the solution of $\sqrt{1-x^2}-y_c=0$ (WLOG, $r=1$).

And

$$\int\sqrt{1-x^2}dx=\frac{x\sqrt{1-x^2}}2-\frac{\arcsin x}2.$$

You need to discuss a little further for the four quadrants.

enter image description here

enter image description here

$\endgroup$
  • $\begingroup$ I'm sorry, I don't quite understand this answer. What is an infinite "corner"? Where are $x_s, y_s$? What do you mean buy "discuss a little further for the four quadrants"? $\endgroup$ – Gabriel Sep 5 '17 at 16:09
  • $\begingroup$ @Gabriel: hope the figure will make it a little clearer. A corner is formed by two perpendicular half-lines. $\endgroup$ – Yves Daoust Sep 5 '17 at 16:09
  • $\begingroup$ Sorry, still lost :( $\endgroup$ – Gabriel Sep 5 '17 at 16:11
  • $\begingroup$ @Gabriel: sorry, I have no more time now. $\endgroup$ – Yves Daoust Sep 5 '17 at 16:12
  • $\begingroup$ No worries I'll look into it with more detail. Thank you for your answer! $\endgroup$ – Gabriel Sep 5 '17 at 16:13

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.