投影几何 - 使用特征值在 3D 中查找平面

Projective Geometry - Find Plane in 3D using eigen

我正在尝试用 3D 中的三个点构建一个平面。 我想用射影几何来实现这个。

据我所知,可以"simply"解决以下问题来找到一架飞机:

A * x = 0 ,where
A is a 3x4 Matrix - each row being one of the points (x,y,z,1)
x is the plane I want to find

我知道我需要约束。因此我想设置x(3) = 1。 有人可以告诉我正确的使用方法吗?

到目前为止我有以下代码:

Eigen::Vector4f p1(0,0,1,1);
Eigen::Vector4f p2(1,0,0,1);
Eigen::Vector4f p3(0,1,0,1);

Eigen::Matrix<float,3,4> A;
A << p1.transpose(), p2.transpose(), p3.transpose();

// Throws compile error
// Eigen::Vector4f Plane = A.jacobiSvd(ComputeThinU | ComputeThinV).solve(Vector4f::Zero()); 

//throws runtime error (row-number do not match)
// Eigen::Vector4f Plane = A.fullPivHouseholderQr().solce(Eigen::Vector4f::Zero()); 

一个 3x4 矩阵乘以一个 4 行向量将得到一个 3 行向量。因此,您必须求解 Vector3f::Zero()。此外,对于固定大小的矩阵,您需要计算完整的 U 和 V。最后一行如下所示:

Vector4f Plane = A.jacobiSvd(ComputeFullU | ComputeFullV).solve(Vector3f::Zero());

首发 由于这个方程组没有完全定义,它可能会给出 (0,0,0,0) 的平凡解。您可以通过将矩阵扩展为 4x4、求解 (0,0,0,1) 并将结果缩放 x(3):

来限制结果向量的长度来解决该问题
Eigen::Vector4f p1(0,0,1,1);
Eigen::Vector4f p2(1,0,0,1);
Eigen::Vector4f p3(0,1,0,1);
Eigen::Vector4f p4(1,1,1,1);

Eigen::Matrix<float,4,4> A;
A << p1.transpose(), p2.transpose(), p3.transpose(), p4.transpose();

// Throws compile error
Eigen::Vector4f Plane = A.jacobiSvd(Eigen::ComputeFullU | Eigen::ComputeFullV).solve(Vector4f::Unit(3)); 
Plane /= Plane(3);

这将为您提供 (-1, -1, -1, 1) 的所需解。