Search code examples
quaternions

Convert quaternions between two coordinate systems where x axis becomes -x


How to estimate new quaternion when x axis becomes -x ?

In short, I need to estimate the new quaternion when rotation around y becomes 180-y.


Solution

  • if angle around y is 30 degrees, around x=20 degrees, and around z is z = 70 degrees then around y should become 180-30 degrees because x becomes -x

    In Quaternions: The new y in -x should be (180-30)*pi/180 and its quaternions are found as follows (original in https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles but for different coordinate system)

            a = 180-30; //180-30;
    
            ax = 20 * Math.PI/180;
            ay = a * Math.PI/180;
            az = 70 * Math.PI/180;
    
            t0 = Math.cos(ay * 0.5);  // yaw
            t1 = Math.sin(ay * 0.5);
            t2 = Math.cos(az * 0.5);  // roll
            t3 = Math.sin(az * 0.5);
            t4 = Math.cos(ax * 0.5);  // pitch
            t5 = Math.sin(ax * 0.5);
    
            t024 = t0 * t2 * t4;
            t025 = t0 * t2 * t5;
            t034 = t0 * t3 * t4;
            t035 = t0 * t3 * t5;
            t124 = t1 * t2 * t4;
            t125 = t1 * t2 * t5;
            t134 = t1 * t3 * t4;
            t135 = t1 * t3 * t5;
    
            x = t025 + t134;
            y =-t035 + t124;
            z = t034 + t125;
            w = t024 - t135;