2
$\begingroup$

Consider a circle located at the origin

circ[R_] := Circle[{0,0},R] 

and an arbitrary rectangle

rect[x1_,y1_,x2_,y2_] := Rectangle[{x1,y1},{x2,y2}]

These figures somehow intersect each other. Could you please tell me how to calculate the fraction of the circle's area $\epsilon = S_{\text{intersection}}/\pi R^{2}$ inside the rectangle, assuming completely arbitrary relative positions (i.e., a circle is inside the rectangle, or the latter is shifted)?

My attempt follows this question:

rectangle = Rectangle[{1, 1}, {2, 2}];
circle = Circle[{0, 0}, 2];
Area[RegionIntersection[rectangle, circle]]

But it gives zero, maybe since RegionIntersection does not compute the 2D region, only a curve of the surface intersections (?).

$\endgroup$
3
  • 3
    $\begingroup$ rectangle = Rectangle[{1, 1}, {2, 2}]; circle = Disk[{0, 0}, 2]; Area[RegionIntersection[rectangle, circle]] $\endgroup$
    – cvgmt
    Mar 10 at 9:17
  • 4
    $\begingroup$ use Disk instead of Circle if you want the area. Or use ArcLength instead of Area if you want the length of the length of the arc. $\endgroup$
    – kglr
    Mar 10 at 9:17
  • $\begingroup$ Thanks to both of you! $\endgroup$ Mar 10 at 9:46
3
$\begingroup$

Conversion of @kglr's and @cvgmt's comments into a community wiki answer (edited slightly for clarity):

@cvgmt:

rectangle = Rectangle[{1, 1}, {2, 2}];
circle = Disk[{0, 0}, 2];
Area[RegionIntersection[rectangle, circle]]

@kglr:

use Disk instead of Circle if you want the area. Or use ArcLength instead of Area if you want the length of the arc.

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