0
$\begingroup$

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?

$\endgroup$

2 Answers 2

1
$\begingroup$

The differences you see are very small (on the order of 1e-7), typical of floating-point arithmetic. Those differences are negligible for most practical purposes but are noticeable when examining the values closely by printing, as you did here.

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.

Those slight differences in the rotation matrix values after this conversion result from Eigen ensuring the rotation matrix is properly normalized, ensuring rotation matrix properties.

$\endgroup$
0
$\begingroup$

They look pretty correct to me? We are talking about a difference of say 0.0000001 between yours and the other one. Try to round up the result. Should give the same.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.