Reputation: 3352
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, i.e.
a 3xN matrix X
where each column represents a vector to be
transformed, i.e.
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.
Upvotes: 0
Views: 1073
Reputation: 29205
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.
Upvotes: 2