Solution (source code)

= Solution

The chosen <unit normal> points toward the plane from the origin, so the plane equation is
$$
\boxed{\mathbf n\cdot\mathbf r=d.}
$$
To locate the circle centre, project $\mathbf p$ onto this <plane>. Put
$$
\gamma=d-\mathbf n\cdot\mathbf p,\qquad
\mathbf h=\mathbf p+\gamma\mathbf n.
$$
Then $\mathbf n\cdot\mathbf h=d$, so $\mathbf h$ lies in the plane. For any other point $\mathbf r$ of the plane, $\mathbf r-\mathbf h$ is perpendicular to $\mathbf n$. The <Pythagorean theorem> therefore gives
$$
|\mathbf r-\mathbf p|^2
=|\mathbf r-\mathbf h|^2+\gamma^2.
$$
Restricting the sphere equation to the plane consequently gives a circle centred at $\mathbf h$. Thus $\mathbf m=\mathbf h$, proving that the displacement of its centre is purely normal:
$$
\boxed{\mathbf m-\mathbf p=\gamma\mathbf n,\qquad
\gamma=d-\mathbf n\cdot\mathbf p.}
$$
The same <Pythagorean theorem> gives $q^2=\rho^2+\gamma^2$, and hence
$$
\boxed{\gamma^2=q^2-\rho^2,\qquad
\gamma=\pm\sqrt{q^2-\rho^2}.}
$$
\b[The sign of $\gamma$ is fixed by which side of the plane contains $\mathbf p$; $q$ and $\rho$ alone determine only its magnitude.] Substituting the signed offset yields the <sphere-plane intersection> radius
$$
\boxed{\rho=\sqrt{q^2-(d-\mathbf n\cdot\mathbf p)^2}.}
$$
A genuine circle requires $|d-\mathbf n\cdot\mathbf p|<q$; equality gives tangency and $\rho=0$, while a larger distance gives no intersection. The <signed distance from a point to a plane> in the direction $\mathbf n$ is $\mathbf n\cdot\mathbf p-d=-\gamma$; the ordinary <distance from a point to a plane> is its absolute value.