# Obtaining rotation and translation matrix from homogeneous transformation matrix

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 code does exactly what is intended. The transformation is created, then the Eigen::Isometry3f object is initialized with this transformation, converting the homogeneous transformation matrix into a form that separates rotation and translation.