Solution (source code)

= Solution

Let the relevant projected <reciprocal lattice vectors> have magnitudes $g_1=1/d_1$ and $g_2=1/d_2$, with angle $\theta$ between them. Subtracting their phases gives the slow spatial modulation $2\pi(\mathbf g_1-\mathbf g_2)\cdot\mathbf r$. The <moiré fringe spacing formula> is therefore
$$
\boxed{D=\frac1{|\mathbf g_1-\mathbf g_2|}=\frac{d_1d_2}{\sqrt{d_1^2+d_2^2-2d_1d_2\cos\theta}}.}
$$
For parallel planes, $\theta=0$ and $D=d_1d_2/|d_1-d_2|$. For equal spacings, $D=d/[2|\sin(\theta/2)|]\simeq d/|\theta|$ at a small angle measured in <radians>. The apparent divergence as both mismatch and <rotation> vanish means that there is no finite beat period; it does not predict an infinite number of visible fringes.