[英]Eigen C++; Euclidean Transformation with Eigen::Transform
Given an Euclidean Transformation by a rotation matrix 3x3 R
and a 3-dimensional translation vector t
, how can the Euclidean transformation be implemented using Eigen::Transform
? 给定通过旋转矩阵3x3 R
和3维平移向量t
进行的欧几里德变换,如何使用Eigen::Transform
实现欧几里德Eigen::Transform
?
X = R * X + t
My current approach fails to work: 我目前的方法行不通:
Eigen::Transform<Type, 3, Eigen::Projective> transformation;
...
Eigen::AngleAxis rotation(R);
Eigen::Translation<Type,3> translation(t);
transformation = translation * rotation;
Now, I want to apply it column-wise on a larger set of vectors, ie a 3xN matrix X
where each column represents a vector to be transformed, ie 现在,我想将其逐列应用于更大的向量集,即3xN矩阵X
,其中每列代表要转换的向量,即
X = transformation * X
But, this does not work and produces an assertion: 但是,这不起作用并产生一个断言:
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.
MBo's comment is right, you used a Projective
transform that involves full homogeneous coordinates to work with. MBo的评论是正确的,您使用了包含完全齐次坐标的Projective
变换。 You need to use an Affine
transform or AffineCompact
if you want a 3x4
matrix under the hood. 如果要在引擎盖下使用3x4
矩阵,则需要使用Affine
变换或AffineCompact
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.