Intersection between a disk and a mesh Consider a wire mesh with infinitesimally small wire and spacing of dimensions $a$ and $b$, with a disk dropped on it of radius $r$, with its centre at $(x,y)\in[r,r+a]\times[r,b+r]$, where the axis are defined as the nearest wires below and to the left of the circle respectively, as shown here?

Is it possible to derive a function which expresses the total length of wire in contact with the interior of the disk as a function of $x,y,a,b$ and $r$, which works for all possible values, ideally with no assumptions being made about the relative sizes of $r$, $a$ and $b$? Anything will be considered helpful, not matter how messy or what approximations need to be made.
 A: This is the way I found. First of all, you need to count the number of wires inside the circle. This number is the sum of numbers of wires south/north/west/east of the center. These are
\begin{eqnarray*}
    \#W_{\mathrm{south}} &=& \left\lfloor \frac{y}{b} \right\rfloor,\\
    \#W_{\mathrm{north}} &=& \left\lfloor \frac{y+r}{b} \right\rfloor - \left\lfloor \frac{y}{b} \right\rfloor,\\
    \#W_{\mathrm{west}} &=& \left\lfloor \frac{x}{a} \right\rfloor,\\
    \#W_{\mathrm{east}} &=& \left\lfloor \frac{x+r}{a} \right\rfloor - \left\lfloor \frac{x}{a} \right\rfloor
\end{eqnarray*}
where $\lfloor x \rfloor$ is rounding towards zero function.
By pythagorean theorem, the length of chord at $h$ from center is
$$
    L_{\mathrm{chord}} = 2\sqrt{r^{2}-h^{2}}.
$$
Therefore, you sum everything getting total length $L=L_{\mathrm{south}}+L_{\mathrm{north}}+L_{\mathrm{west}}+L_{\mathrm{east}}$ where
\begin{eqnarray*}
    L_{\mathrm{south}} = 2\sum\limits_{k=0}^{\#W_{\mathrm{south}}-1} \sqrt{r^{2}-(y-b(\#W_{\mathrm{south}}-k))^{2}},\\
    L_{\mathrm{north}} = 2\sum\limits_{k=1}^{\#W_{\mathrm{north}}} \sqrt{r^{2}-(y-b(\#W_{\mathrm{south}}+k))^{2}},\\
    L_{\mathrm{west}} = 2\sum\limits_{k=0}^{\#W_{\mathrm{west}}-1} \sqrt{r^{2}-(x-a(\#W_{\mathrm{west}}-k))^{2}},\\
    L_{\mathrm{east}} = 2\sum\limits_{k=1}^{\#W_{\mathrm{east}}} \sqrt{r^{2}-(x-a(\#W_{\mathrm{west}}+k))^{2}}.
\end{eqnarray*}
