Does the quaternion that Eigen extracts from an Affine3d 3x3 rotation matrix is normalized?

2.1k Views Asked by At

here https://docs.ros.org/kinetic/api/eigen_conversions/html/eigen__msg_8cpp_source.html#l00093

I quite do not understand the syntax of this line : Eigen::Quaterniond q = (Eigen::Quaterniond)e.linear();

But anyway, assuming e is of type Eigen::Affine3d (3x3 rotation matrix), where can I figure out how a quaternion is constructed fron a rotation matrix in Eigen library please? I did not saw any method on the doc, except https://eigen.tuxfamily.org/dox/classEigen_1_1QuaternionBase.html#title25 but I'm a real noob in c++ so I do not even understand that one...

I hope it does something like this https://arc.aiaa.org/doi/abs/10.2514/2.4654?journalCode=jgcd because my need is that the extracted quaternion must be normalized, and I would like to ensure this.

1

There are 1 best solutions below

2
On

You can ensure that your Eigen::Quaterniond is normalised by calling it's normalize() method.

The line in question is explicitly converting whatever e.linear() returns to a Eigen::Quaterniond.

As to how you go from a rotation matrix to a quaternion, Wikipedia describes the relationship. It's just solving a known set of simultaneous equations. I expect the body of the method to look (more or less) like a bunch of algebra.