From Ohm

# Barycentric Interpolation in a Tetrahedron

An interpolated scalar value at the point $\vec{v}$ within the domain of a tetrahedron is determined by the barycentric interpolation of corner scalar values $s_{1/2/3/4}$ at the corner points $\vec{v}_{1/2/3/4}$. The barzcentric interpolation is a linear combination of the scalar values with linear weights $w_{1/2/3/4}$:

$f(\vec{v}) = f(w_1,w_2,w_3,w_4) = w_1s_1 + w_2s_2 + w_3s_3 + w_4s_4$ with
$w_1 = det(\vec{v_2}-\vec{v},\vec{v_3}-\vec{v},\vec{v_4}-\vec{v}) D^{-1}$
$w_2 = det(\vec{v_1}-\vec{v},\vec{v_3}-\vec{v},\vec{v_4}-\vec{v}) D^{-1}$
$w_3 = det(\vec{v_1}-\vec{v},\vec{v_2}-\vec{v},\vec{v_4}-\vec{v}) D^{-1}$
$w_4 = det(\vec{v_1}-\vec{v},\vec{v_2}-\vec{v},\vec{v_3}-\vec{v}) D^{-1}$
$D = det(\vec{v_4}-\vec{v_1},\vec{v_3}-\vec{v_1},\vec{v_2}-\vec{v1})$

In a triangle:

In a tetrahedron: