Solution (source code)

= Solution

For the remaining distance calculation with $b=c$, every point on the line is $a+tb$. The nearest point to $p$ is found by <orthogonal projection> onto $b$:
$$
t_* =\frac{(p-a)\cdot b}{|b|^2},\qquad
\boxed{d(p,S)=\left|(p-a)-\frac{(p-a)\cdot b}{|b|^2}b\right|=\frac{|(p-a)\times b|}{|b|}.}
$$
Indeed, differentiating $|a+tb-p|^2$ sets its component along $b$ to zero. Its second derivative is $2|b|^2>0$, proving this is the minimum.