# Formula for area of circle sector inside rectangle

Pretend that I have an $W$x$H$ rectangle, inside of which there is a given point. Let's set up coordinates: (0,0) is at the bottom left of the rectangle, and the point is at (x,y), with 0<=x<=W and 0<=y<=H. From this point, I draw a sector of a circle which can be pointing in any direction $\phi$, and has angular width $\theta$ and radius $R$. The sector might have some (or all) of its area outside the rectangle, depending on the configuration and the parameters.

I want an expression, $A(W,H,\theta,\phi,R,x,y)$ for the area of the sector that is inside the rectangle. It will be a piece-wise expression with multiple pieces corresponding to different geometric situations, e.g. the chord of the sector is completely outside the rectangle so the only overlapping area is a part of a triangle, etc.

• You'll need another parameter $\phi$ which denotes the angle of one of the sides of the sector. (I'm assuming that $\theta$ is the angular width of the sector.) – John Dec 16 '16 at 23:39
• yeah sorry you're right. Updated accordingly. – sambajetson Dec 17 '16 at 0:44

Depending on the value of $\theta$ and $\phi$, the locations of Y, U, M, V, Y may vary. We only discuss the simplest case. (I think the same logic is applicable to other cases.)

When $\theta$ and $\phi$ are known, U and V are found (and assumed) to be located on the top edge of the rectangle.

0) Find the co-ordinates of X, U, M, V, Y.

1) Find $[\triangle PUM]$.

2) Find all the sides of $\triangle PMV$.

3) Find $\alpha$ by cosine law.

4) Find [sector PMY].