Tetrahedron membership via scalar triple products (source code)

= Tetrahedron membership via scalar triple products

Let $D=\mathbf a\cdot(\mathbf b\times\mathbf c)>0$. The <reciprocal basis> gives the coordinates of any <position vector> as
$$
\alpha=\frac{\mathbf r\cdot(\mathbf b\times\mathbf c)}D,\qquad
\beta=\frac{\mathbf r\cdot(\mathbf c\times\mathbf a)}D,\qquad
\gamma=\frac{\mathbf r\cdot(\mathbf a\times\mathbf b)}D.
$$
The point lies in the closed <tetrahedron> with vertices $0,\mathbf a,\mathbf b,\mathbf c$ exactly when $\alpha,\beta,\gamma\geq0$ and $\alpha+\beta+\gamma\leq1$. Indeed, these conditions express it as a <convex combination> of the four vertices, with fourth weight $1-\alpha-\beta-\gamma$. They also describe the intersection of the four inward <half-spaces> bounded by its faces. Strict inequalities characterize its interior.