Circle of intersection of two spheres (source code)

= Circle of intersection of two spheres
{title2=$|p-q|<|b-a|<p+q$}

Two <spheres> with centres $a,b$ and positive radii $p,q$ intersect in a nondegenerate <circle> exactly under the displayed strict triangle inequalities. Put $d=|b-a|$. Subtracting $|r-a|^2=p^2$ and $|r-b|^2=q^2$ gives its plane,
$$
2(b-a)\cdot r=p^2-q^2+|b|^2-|a|^2.
$$
The circle centre is $a+\ell(b-a)/d$, where $\ell=(p^2-q^2+d^2)/(2d)$, and its squared radius is $p^2-\ell^2$. This is positive exactly under the strict inequalities. Equality gives internal or external tangency; coincident equal <spheres> have an entire sphere in common rather than a unique intersection circle.