Center and radius of a sphere-plane intersection (source code)

= Center and radius of a sphere-plane intersection
{title2=$b=c+(p-n\cdot c)n$, $\rho^2=a^2-(p-n\cdot c)^2$}

For a <sphere> with centre $c$ and radius $a$, and a <plane> $n\cdot r=p$ with unit normal $n$, the orthogonal projection of $c$ onto the <plane> is $b=c+(p-n\cdot c)n$. The orthogonal decomposition $r-c=(r-b)+(b-c)$ gives the intersection <circle> radius by the <Pythagorean theorem>. A genuine <circle> requires $|p-n\cdot c|<a$; equality gives tangency and larger distance gives no intersection. The signed displacement is not determined by the two radii alone: it is $\pm\sqrt{a^2-\rho^2}$ with sign fixed by the oriented <plane>.