Barycentric coordinates of a tetrahedron

后端 未结 1 598
遥遥无期
遥遥无期 2021-01-15 21:58

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

相关标签:
1条回答
  • 2021-01-15 22:27

    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);
    }
    
    0 讨论(0)
提交回复
热议问题