从重心坐标系到笛卡尔坐标系

12

我有以下函数,可以将与三角形在同一平面上的点转换为重心坐标。

// p0, p1 and p2  and the points that make up this triangle
Vector3d Tri::barycentric(Vector3d p) {
    double triArea = (p1 - p0).cross(p2 - p0).norm() * 0.5;
    double u = ((p1 - p).cross(p2 - p).norm() * 0.5) / triArea;
    double v = ((p0 - p).cross(p2 - p).norm() * 0.5) / triArea;
    double w = ((p0 - p).cross(p1 - p).norm() * 0.5) / triArea;
    return Vector3d(u,v,w);
}

我该如何编写这个操作的逆运算?我想编写一个函数,它接受重心坐标并返回笛卡尔点。

1个回答

18

一个点的笛卡尔坐标可以通过将重心坐标作为系数进行线性组合来计算:

Vector3d Tri::cartesian(const Vector3d& barycentric) const
{
      return barycentric.x * p0 + barycentric.y * p1 + barycentric.z * p2;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接