Well, I guess I'll take a stab at this. This is definitely a calculus problem. To take the area between two curves, you want to take the integral of the greater function minus the lesser function. For the yellow area, the greater function is $y=1$. The lesser function will take some manipulation. The formula for the circle is:
$(x-4)^2+(y-4)^2=16$
$(y-4)^2=16-(x-4)^2$
$y-4=-\sqrt{16-(x-4)^2}$
$y=4-\sqrt{16-(x-4)^2}$
So our integral is $\int^3_2[1-(4-\sqrt{16-(x-4)^2}]dx$=$\int^3_2-3dx+\int^3_2\sqrt{16-(x-4)^2}dx$. The first integral is $-3x$ evaluated from 2 to 3, or in other words, $-3(3)-[-3(2)]=-9+6=-3$.
For the second half of that integral, we'll use the info from Andreas's comment. We'll perform a change of variable
$u=x-4,du=dx$
$\int^3_2\sqrt{16-(x-4)^2}dx=\int^{-1}_{-2}\sqrt{16-u^2}du=\frac12[u\sqrt{16-u^2}+16sin^{-1}\frac u4]^{-1}_{-2}=\frac12[(x-4)\sqrt{16-(x-4)^2}+16sin^{-1}\frac{x-4}4]^3_2$
That solves the yellow area. For the other 2, you'll want to know where the 2 functions cross.
$(x-4)^2+(1-4)^2=16$
$(x-4)^2=7$
$x=4-\sqrt7$
For the green area, the 2 functions are the same, but it's evaluated from $4-\sqrt7$ to 2. For the orange area, the greater function is $y=2$, but the lesser function changes. It should be easy to see, though, that the right half is a rectangle. The left half is integrated from 1 to $4-\sqrt7$. Also, the first half of the integral has changed from $\int-3dx$ to $\int-2dx=-2x$. So the total orange area is $2x-\frac12[(x-4)\sqrt{16-(x-4)^2}+16sin^{-1}\frac{x-4}4]$ evaluated from 1 to $4-\sqrt7$ plus $1[2-(4-\sqrt7)]$, or $\sqrt7-2$.
In addition to the answer pointed out by @n_b I would like to show how to reach there:
The final result:
$$\LARGE\boxed{R=\frac H2+\frac{W^2}{8H}}$$
float cos_t = (R-H)/R;
P_x=(rect.width/2);
P_y=-R.cos_t;
Process:
Without using calculus(actually it would never be solved with calculus) and only using trigonometry:
The component of R along $\theta$ is $R.\cos\theta$ and perpendicular to it is $R.\sin\theta$
Now remaining component is $R-Rcos\theta=R(1-\cos\theta)$
Now we have:
$$
W=2.R.\sin\theta\implies\sin\theta=\frac W{2R}\\
H=R(1-\cos\theta)\implies\cos\theta=1-\frac HR=\frac{R-H}R
$$
Using the identity $\sin^2\theta+\cos^2\theta=1$
$$\left(\frac W{2R}\right)^2+\left(\frac{R-H}R\right)^2=1$$
$$\frac{W^2}{4R^2}+\frac{R^2+H^2-2RH}{R^2}=1\\\text{ I assume you are familiar with }(a\pm b)^2=a^2+b^2\pm 2ab$$
$$\frac{W^2}4+R^2+H^2-2RH=R^2$$
$$\frac{W^2}4+H^2=2RH$$
$$R=\frac{W^2}{8H}+\frac H2$$
It is easy to see that center is at the midpoint of width.
Also y-coordinate is $-R.\cos\theta$
Best Answer
You can break up the overlapping area into a segment and a triangle by drawing a diagonal line between the two intersection points and then the formulae for the areas of each of these shapes are very well known. Subtracting these areas from the area of the whole circle will then give you your answer.