I have following piece of code:
Eigen::Matrix4f transformation = myMethod(); // homogenous transformation matrix
std::cout << "transformation = " << std::endl << transformation << std::endl << std::endl;
Eigen::Isometry3f estimate = Eigen::Isometry3f(transformation);
r = estimate.rotation(); // rotation matrix
t = estimate.translation(); // translation matrix
std::cout<<"r = " << std::endl << r << std::endl << std::endl;
std::cout<<"t = " << std::endl << t << std::endl << std::endl;
It prints:
transformation =
1.0000002384185791 4.9265406687482027e-07 -4.5500800638365035e-07 -2.384185791015625e-07
-5.2062489430682035e-07 1.0000003576278687 5.4357258250092855e-07 -3.5762786865234375e-07
4.9866633844430908e-07 -4.6970637868071208e-07 1.0000002384185791 -2.384185791015625e-07
0 0 0 1
r =
1.0000001192092896 7.2572328235764871e-07 -3.9811814644963306e-07
-6.7004600623477018e-07 0.99999994039535522 4.5586514829665248e-07
5.422648428066168e-07 -4.4537293319990567e-07 0.99999994039535522
t =
-2.384185791015625e-07
-3.5762786865234375e-07
-2.384185791015625e-07
Here, I am trying to obtain rotation and translation matrices from homogeneous transformation matrix. I guess translation matrix is the first three elements of the last column of homogeneous matrix and rotation matrix is top left 3x3 matrix. Translation matrix is returned correctly above. But rotation matrix is not exactly the top left 3x3 matrix of the homogeneous matrix.
I guess I am missing some basic concept here. What am doing wrong?
The documentation of
Transformdescribes the different storage modes:inverse()androtation().And this actually happens,
Isometrysimply returns what was stored in the constructor:But, this is version v3.4. As @chtz points out in the comment, this description and the optimization itself are not present in v3.3,
rotationuses no "switchboard", but directly calls a fixed function:computeRotationScaling(the method directly below the linked one) then calculates SVD, and that's where numerical inaccuracies can get introduced:Isometryin v3.3 is practically anAffinewith some parts switched off (likescalestops you with an assert, and there are some more).Seemingly you're using an older version of the library. Consider trying the code with v3.4.