Closest point on the intersection of two planes (source code)

= Closest point on the intersection of two planes
{title2=$a=\alpha b+\beta c$}

For two <planes> $r\cdot b=\lambda$ and $r\cdot c=\mu$ with <linearly independent> <normal vectors>, put $B=b\cdot b$, $C=c\cdot c$, $D=b\cdot c$ and $\Delta=BC-D^2>0$. Their intersection is a <line> parallel to $b\times c$. Its closest point to the origin is <orthogonal> to that direction, hence has the form $a=\alpha b+\beta c$. The constraints give $B\alpha+D\beta=\lambda$, $D\alpha+C\beta=\mu$, so
$$
\alpha=\frac{C\lambda-D\mu}{\Delta},\qquad
\beta=\frac{B\mu-D\lambda}{\Delta},\qquad
|a|^2=\frac{C\lambda^2-2D\lambda\mu+B\mu^2}{\Delta}.
$$
For every other point $a+t(b\times c)$, <orthogonality> gives squared distance $|a|^2+t^2|b\times c|^2$, proving the global minimum and its uniqueness. The positive <determinant> $\Delta=|b\times c|^2$ also proves that an intersection exists for every real $\lambda,\mu$. Parallel normals require a separate consistency check and do not define a unique intersection line.