在x轴变为-x的两个坐标系之间转换四元数

时间:2017-07-03 15:34:34

标签: quaternions

当x轴变为-x?

时,如何估计新的四元数

简而言之,当y周围的旋转变为180度时,我需要估计新的四元数。

1 个答案:

答案 0 :(得分:0)

如果y周围的角度是30度,x = 20度左右,z周围是z = 70度那么y周围应该变成180-30度,因为x变成-x

在四元数中: -in中的新y应为(180-30)* pi / 180,其四元数如下所示(原https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles但不同的坐标系)

        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;