Barycentric coordinates of a tetrahedron

∥☆過路亽.° 提交于 2019-12-01 12:22:33

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);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!