I would like to ask for help regarding barycentric coordinates of a tetrahedron:
Following an approach I found here: http://www.cdsimpson.net/2014/10/barycentric-co
Blind guess:
Vec4f bary_tet(const Vec3f & a, const Vec3f & b, const Vec3f & c, const Vec3f & d, const Vec3f & p)
{
Vec3f vap = p - a;
Vec3f vbp = p - b;
Vec3f vab = b - a;
Vec3f vac = c - a;
Vec3f vad = d - a;
Vec3f vbc = c - b;
Vec3f vbd = d - b;
// ScTP computes the scalar triple product
float va6 = ScTP(vbp, vbd, vbc);
float vb6 = ScTP(vap, vac, vad);
float vc6 = ScTP(vap, vad, vab);
float vd6 = ScTP(vap, vab, vac);
float v6 = 1 / ScTP(vab, vac, vad);
return Vec4f(va6*v6, vb6*v6, vc6*v6, vd6*v6);
}