简体   繁体   中英

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 ?

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

 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. You need to use an Affine transform or AffineCompact if you want a 3x4 matrix under the hood.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM