Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72103

Conversion between QQuaternion and Euler angles has issues in special cases

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.15.13, 6.4.0 Beta1
    • 5.11.2, 6.2
    • Qt3D, Quick: 3D
    • None
    • Windows
    • 6ffc8d8eb6 (qt/qtbase/dev) 28d2e224a1 (qt/qtbase/6.2) 28d2e224a1 (qt/tqtc-qtbase/6.2) 6ffc8d8eb6 (qt/tqtc-qtbase/dev), e2bc6e027 (tqtc/lts-5.15), 1e5ae32c5 (tqtc/lts-5.15)

    Description

      In certain cases (related to gimbal lock?) I'm getting inconsistent results moving between quaternion and Euler angle representations.

      E.g.:

      QVector3D eulerAngles1(90.f, -90.f, 0.f);
      QQuaternion quaternion1 = QQuaternion::fromEulerAngles(eulerAngles1);
      QVector3D eulerAngles2 = quaternion1.toEulerAngles();
      QQuaternion quaternion2 = QQuaternion::fromEulerAngles(eulerAngles2);
      qDebug() << eulerAngles1;
      qDebug() << quaternion1;
      qDebug() << eulerAngles2;
      qDebug() << quaternion2;
      

      produces

      QVector3D(90, -90, 0)
      QQuaternion(scalar:0.5, vector:(0.5, -0.5, 0.5))
      QVector3D(89.972, 0, 0)
      QQuaternion(scalar:0.707279, vector:(0.706934, 0, 0))
      

      And it isn't a matter of ambiguity. Those two quaternions are two totally different orientations. Is it toEulerAngles() where it goes wrong?

      Also, does the following description in the documentation apply?

      Creates a quaternion that corresponds to a rotation of eulerAngles: eulerAngles.z() degrees around the z axis, eulerAngles.x() degrees around the x axis, and eulerAngles.y() degrees around the y axis (in that order).

      As far as I can interpret what I'm seeing, the order seems to be the opposite, y-x-z.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              inho Inho Lee
              jaakko.rantala Jaakko Rantala
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: