Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMatrix, QQuaternion Confusion

QMatrix, QQuaternion Confusion

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 723 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PatrickW
    wrote on last edited by PatrickW
    #1

    Hello,

    for the communication with another program I need to convert a Transformmatrix into a QQuaternion and back. This worked so far. (Maybe because both convertion ways where wrong so it compensated the mistake. )

    But since I added another conversion for special cases which only reads the EulerAngles of the quat, the sened X-Rotation can turn out as Z-Rotation on the other side so there must be something wrong with the order of the values in the ctors.

    The docu is not telling much so hopefully someone can see the mistake:


    Convert MyMatrix to QMatrix:

    float values[] = { uVec.x, uVec.y, uVec.z,
    				vVec.x, vVec.y, vVec.z,
    				wVec.x, wVec.y, wVec.z  };
    
      QMatrix3x3 rotatioMa (values); 
    

    Convert QMatrix to MyMatrix:

    // Column-major order

    uVec (qMatrix.data()[0], qMatrix.data()[3], qMatrix.data()[6]); // x y z
    vVec (qMatrix.data()[1], qMatrix.data()[4], qMatrix.data()[7]); // x y z
    wVec (qMatrix.data()[2], qMatrix.data()[5], qMatrix.data()[8]); // x y z
    

    Converting euler angles to a Quaternion:

    QQuaternion::fromEulerAngles( yRot_Pitch, zRot_Yaw, xRot_Roll); // I looked in wikipedia which axis are used for pitch, yaw and roll
    

    regards,
    Patrick

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should use the copyDataTo method store the matrix values and use the constructor which takes a pointer to reload them.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        You should use the copyDataTo method store the matrix values and use the constructor which takes a pointer to reload them.

        P Offline
        P Offline
        PatrickW
        wrote on last edited by
        #3

        @SGaist

        Thanks for your answer.
        I guess you think I copy one QMatrix to another but the original Matrix has a different type.

        Meanwhile I totally replaced the QMatrix by the QQuaternion but still the XAngle turns out as Z at the other side. Pretty sure the problem is the order of the euler angles in the QuatCtor.

        This is the declaration:

        QQuaternion.fromEulerAngles(float pitch, float yaw, float roll);
        

        As mentioned I used the angles in the following order:

        fromEulerAngles(yRot, zRot, xRot);
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          So you go from QMatrix3x3 to your own matrix and then QQuaternion through fromEulerAngles ?
          What if you use fromRotationMatrix ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved