How do you calculate the area of the intersection between a rectangle and a doughnut? I'm dealing with an engineering problem, involving concentric pipes, with air flowing through the outer pipe (doughnut).
I need a cross-beam to support the inner pipe, so I need to calculate how much of the outer doughnut's area will be consumed by the cross beam, in order to determine aerodynamic impact on the airflow through the outer circle of the doughnut.
The picture below illustrates what I'm trying to do.
I need to calculate the area of the gold section.
The actual height of the blue rectangle is irrelevant - it crosses both circles exactly twice, it is perpendicular to the axes, and it is centered over the vertical axis.
The intersection is fully rounded on both ends, exactly meeting the edges of both circles.


The equations for the upper semicircles of the small pipe and large pipe are $f(x) = \sqrt{r^2 - x^2}$ and $g(x) = \sqrt{R^2 - x^2}$ respectively. The area of the cross-beam is then found by integrating $g(x) - f(x)$ over the interval $[-\frac{w}{2}, \frac{w}{2}]$:
\begin{align*}
\int_{-w/2}^{w/2} (g(x) - f(x))\,dx &= \int_{-w/2}^{w/2} g(x)\,dx - \int_{-w/2}^{w/2} f(x)\,dx \\
&= \int_{-w/2}^{w/2} \sqrt{R^2 - x^2}\,dx - \int_{-w/2}^{w/2} \sqrt{r^2 - x^2}\,dx \\
&= \left[\frac{1}{2} x \sqrt{R^2-x^2} 
+\frac{1}{2}R^2\arctan\frac{x}{\sqrt{R^2-x^2}}\right]^{w/2}_{-w/2} - \left[\frac{1}{2} x \sqrt{r^2-x^2} 
+\frac{1}{2}r^2\arctan\frac{x}{\sqrt{r^2-x^2}}\right]^{w/2}_{-w/2} \tag 1
\end{align*}
I should note that this is somewhat incomplete; I don't know if it's possible to simplify this expression before calculating it. That said, it should be possible to calculate it from this point.
David Quinn pointed out that $\arctan\frac{x}{\sqrt{R^2-x^2}}=\arcsin\frac xR$ (which follows from the definitions of $\sin$ and $\tan$). Using this, we can simplify equation $(1)$ as
\begin{align*}
\left[\frac{1}{2} x \sqrt{R^2-x^2} 
+\frac{1}{2}R^2\arctan\frac{x}{\sqrt{R^2-x^2}}\right]^{w/2}_{-w/2} - \left[\frac{1}{2} x \sqrt{r^2-x^2} 
+\frac{1}{2}r^2\arctan\frac{x}{\sqrt{r^2-x^2}}\right]^{w/2}_{-w/2} &= \left[\frac{1}{2} x \sqrt{R^2-x^2} 
+\frac{1}{2}R^2\arcsin\frac{x}{r}\right]^{w/2}_{-w/2} - \left[\frac{1}{2} x \sqrt{r^2-x^2} 
+\frac{1}{2}r^2\arcsin\frac{x}{r}\right]^{w/2}_{-w/2} \tag 2
\end{align*}
Evaluating each part of $(2)$ for $x = -\frac{w}{2}$ to $x = \frac{w}{2}$, we have [INCOMPLETE]
\begin{align*}
\left[\frac{1}{2} x \sqrt{R^2-x^2} 
+\frac{1}{2}R^2\arcsin\frac{x}{r}\right]^{w/2}_{-w/2} - \left[\frac{1}{2} x \sqrt{r^2-x^2} 
+\frac{1}{2}r^2\arcsin\frac{x}{r}\right]^{w/2}_{-w/2} &= 
\frac{w}{2}\sqrt{R^2 - x^2} - \frac{w}{2}\sqrt{r^2 - x^2} (+ \ldots)
\end{align*}
