internal rectangle area intersected by a circle

361 Views Asked by At

I need to compute the internal rectangle area intersected by a circle like (the blue area) on these 3 examples:

enter image description here

I know every vertex (x,y) coordinate and then their distance from circle center but is there a way to know the area of the rectangle portions that falls inside the circle?

I'm definitively not a mathematician and I've read something about Simpson's rule. Can this rule be applied for my need?

Thanks in advance. Stefano, Milan, Italy

2

There are 2 best solutions below

2
On BEST ANSWER

Take your origin as the center of the circle, which has radius $r$.

Your rectangles are in the first quadrant, so let's take $x$ as a function of $y$ to express the circle:

$$x(y) = \sqrt{r^2-y^2}.$$

Take the points to be $(x_A, y_A), (x_B, y_B), (x_C, y_C), (x_D, y_D).$

Then your shaded area is

$$\left[\int_{y_C}^{y_A} \sqrt{(r^2 - y^2)} dy\right] - x_A(y_A - y_C)$$

$$= \frac{y_A}{2} \sqrt{r^2 - y_A^2} - \frac{y_C}{2} \sqrt{r^2 - y_C^2} + \frac{r^2}{2} \tan^{-1} \frac{y_A}{\sqrt{r^2 - y_A^2}} - \frac{r^2}{2} \tan^{-1} \frac{y_C}{\sqrt{r^2 - y_C^2}} - x_A(y_A - y_C).$$

0
On

Analytical geometry is enough.

You can find the intersection between the circle and an horizontal or vertical edge by solving $R\sin\theta=Y$ or $R\cos\theta=X$ for $\theta$. Repeat this for the two rectangle edges that cross the circle, and by difference you get the aperture of the arc inside the rectangle.

To determine the two relevant edges, find the pairs of vertices that are on either side of the circle ($X^2+Y^2\gtrless R^2$).

Then the desired area is the sum of 1) the polygon formed by the sides and portions of sides inside the circle and the chord of the arc, and 2) the circular segment between the arc and the chord.

enter image description here

The area of the polygon is found by that formula , and the area of the segment by this one.