# Convention for QQuaternion conversion to/from Euler Angles

• Hello all,

This should be a fairly straightforward question. I was wondering what the convention is that Qt uses for converting between quaternions and Euler angles?

The documentation says that the conversion corresponds "to a rotation of roll degrees around the z axis, pitch degrees around the x axis, and yaw degrees around the y axis (in that order)". Ignoring the confusing use of pitch, roll, yaw nomenclature (which is different than what I've seen in the aerospace industry), this implies that the quaternion is assuming a 2-1-3 euler rotation sequence (https://www.astro.rug.nl/software/kapteyn-beta/_downloads/attitude.pdf). However, the source code for the QQuaternion doesn't seem to agree with this.

Additionally, does Qt assume body rotations (intrinsic) or rotations with respect to fixed axes (extrinsic)? I'm assuming that Qt assumes body rotations, but I'm not sure on that.

Any ideas what convention is actually being used? It's important as I'm trying to interface with other code that uses Euler Angles with arbitrary configurations. Thanks all.

• @feistykittykat As an addendum to this, it appears that the documentation on QQuaternion is incorrect, and reverses the convention. Their math is consistent with a conversion from a 3-1-2 body Euler rotation.

• Ignoring the confusing use of pitch, roll, yaw nomenclature (which is different than what I've seen in the aerospace industry)

AFAIK, yaw, pitch and roll are commonly used for robotics, but it is also mentioned as Aircraft principal axes.

But unfortunately I have absolut no knowledge about quaternions, I would compare the calculated angles from Qt with the specific formulas. Here is also an online conversion from quaternions to euler angles.

• @beecksche Sure, I'm familiar with the terminology, it's just that in my experience, roll is about the x-axis of the craft, yaw is about the z-axis, and pitch is about the y-axis. It's just a convention. My real gripe is that the math doesn't seem to match. I appreciate the tool that you've linked, but it doesn't really get to the crux of my question, which is whether or not Qt is actually using a 2-1-3 (Y-X-Z) sequence.

• @feistykittykat

If you think the docs are wrong, you can submit a bug to https://bugreports.qt.io/

The math of the QQuaternion is based on: http://www.j3d.org/matrix_faq/matrfaq_latest.html

See the source code

Maybe this helps