【问题标题】:From barycentric to cartesian从重心到笛卡尔
【发布时间】:2012-06-29 13:08:19
【问题描述】:

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

// 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);
}

我怎样才能写出这个操作的逆运算?我想编写一个以重心坐标为参数并返回笛卡尔点的函数。

【问题讨论】:

    标签: c++ math 3d coordinate-systems


    【解决方案1】:

    一个点的笛卡尔坐标可以计算为以重心坐标为系数的线性组合:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-13
      • 2016-11-22
      • 2012-02-24
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      • 2016-04-21
      相关资源
      最近更新 更多