0
votes

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.
1
X should be 4*1 vector from the same typeHumam Helfawi
You mean, that internally, it generates a 4x3 matrix to combine the rotation and translation. But does this really force me to generate a forth-dimension element? Is there an elegant way around that?Frank-Rene Schäfer
Read about homogeneous coordinates. BTW, do you really need Projectiverather than Affine?MBo

1 Answers

2
votes

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.