Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Quaternion rotation axles swaps after 90º of rotation

Quaternion rotation axles swaps after 90º of rotation

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 489 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.
  • A Offline
    A Offline
    avmg
    wrote on last edited by
    #1

    Hi all!

    I have a qml script that rotates an object in 3d space. In order to avoid the gimbal lock I am using quaternions. So when I rotate the object 90 degrees through one axle, lets say roll, the yaw and pitch rotation axles are swaped... Somehow I think the problem is with the rotation instructions I am following, I mean taking the actual quaternion and multiplaying it by the new quaternion...

    Here I attach my instructions to show where can be my error. Many thanks in advance!

    function paintGL(canvas,q0,q1,q2,q3) {
        var endQuaternion = new THREE.Quaternion();
        var vector = new THREE.Vector3(1, 0, 0);
        endQuaternion.set( q2, q0, q1, q3 );   //The order is modified to match with the object movements
        var rotationQuaternion = new THREE.Quaternion();
        rotationQuaternion.setFromAxisAngle(new THREE.Vector3( 1, 0, 0 ), -Math.PI / 2);  //Rotate the object to the desired starting point
        endQuaternion.multiply(rotationQuaternion);
        var qm = new THREE.Quaternion();
        THREE.Quaternion.slerp(mesh.quaternion, endQuaternion, qm, 0.5);
        mesh.quaternion.slerp(qm, 0.5);
        renderer.render( scene, camera );
    }
    
    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