2

Hi I have obtained the Transformation Matrix which looks like this

transformation matrix:

-0.999702 -0.00155921  -0.0243653     0.62702
        0    0.997959  -0.0638626   -0.287402
-0.0244151   0.0638436    0.997661  -0.0212277
       0           0           0           1

I would like to convert the Transformation matrix to rotation matrix and then to Quaternion. I know that the rotation matrix can be converted to Quaternion in C++ using getQuaternionFromRotationMatrix. But my problem is how to transform the Transformation matrix I have into rotation one.

Any help? Thanks

Scheff's Cat
  • 19,528
  • 6
  • 28
  • 56
Macedon971
  • 303
  • 2
  • 11
  • 1
    The rotation matrix is the upper-left 3x3 matrix assuming there are only translations and rotations but no shearing nor scaling. – Scheff's Cat Jun 26 '20 at 05:34
  • 3
    FYI: [SO: Eigen: convert Matrix3d rotation to Quaternion](https://stackoverflow.com/q/21761909/7478597), [SO: Eigen: convert rotation matrix to quaternion then back getting completely different matrices](https://stackoverflow.com/q/46967752/7478597), [SO: Eigen: matrix to quaternion and back have different result](https://stackoverflow.com/questions/43896041/eigen-matrix-to-quaternion-and-back-have-different-result). More: [google "eigen getQuaternionFromRotationMatrix"](https://www.google.com/search?q=eigen+getQuaternionFromRotationMatrix) ;-) – Scheff's Cat Jun 26 '20 at 05:35
  • ok. Thanks so I just use the upper left 3x3 matrix of the transformation matrix and then getQuaternionFromRotationMatrix right? – Macedon971 Jun 26 '20 at 09:03
  • Yes. This will work if the matrix was built exclusively from rotations and translations (regardless of how many of them). – Scheff's Cat Jun 26 '20 at 09:08
  • I have done it but gon an Error. Eigen::Matrix3f Rotation_matrix = transformationMatrix.topLeftCorner<3,3>(); auto Quaternion = Rotation_matrix.getQuaternionFromRotationMatrix(); Error is Eigen::Matrix3f {aka class Eigen::Matrix}’ has no member named ‘getQuaternionFromRotationMatrix’ Any help? – Macedon971 Jun 27 '20 at 04:38
  • Just write `Eigen::Quaternionf quaternion(transformationMatrix.topLeftCorner<3,3>());` If that does not work, post a [mre]. – chtz Jun 27 '20 at 09:48

0 Answers0