【发布时间】:2018-01-22 13:56:31
【问题描述】:
给定一个由旋转矩阵 3x3 R 和一个 3 维平移向量 t 进行的欧几里得变换,欧几里得变换如何
使用Eigen::Transform 实现?
X = R * X + t
我目前的方法不起作用:
Eigen::Transform<Type, 3, Eigen::Projective> transformation;
...
Eigen::AngleAxis rotation(R);
Eigen::Translation<Type,3> translation(t);
transformation = translation * rotation;
现在,我想将它按列应用于更大的向量集,即
一个 3xN 矩阵 X 其中每一列代表一个向量
转换,即
X = transformation * X
但是,这不起作用并产生一个断言:
test-depth.exe: /usr/include/eigen3/Eigen/src/Core/Product.h:133: Eigen::Product<Lhs, Rhs, Option>::Product(const Lhs&, const Rhs&) [with _Lhs = Eigen::Matrix<double, 4, 4>; _Rhs = Eigen::Matrix<double, -1, -1>; int Option = 0; Eigen::Product<Lhs, Rhs, Option>::Lhs = Eigen::Matrix<double, 4, 4>; Eigen::Product<Lhs, Rhs, Option>::Rhs = Eigen::Matrix<double, -1, -1>]: Assertion `lhs.cols() == rhs.rows() && "invalid matrix product" && "if you wanted a coeff-wise or a dot product use the respective explicit functions"' failed.
【问题讨论】:
-
X 应该是同类型的 4*1 向量
-
您的意思是,在内部,它会生成一个 4x3 矩阵来组合旋转和平移。但这真的会迫使我生成一个四维元素吗?有没有一种优雅的方法?
-
了解齐次坐标。顺便说一句,你真的需要
Projective而不是Affine吗?
标签: c++ geometry linear-algebra eigen eigen3