Rotate a Quaternion with Euler angles using Eigen

I'm trying to create a quaternion, rotate it around Euler-Angles and transform it back to Euler Angles. I am using Eigen. Convert from Euler to Quaternion and vice versa works fine, but when i rotate around using Angle Axis my values are off about 20 - 50%. For example when i try to rotate from 0,0,0 to 90,50,60 i get x: 75,5 y: 103,13, z: 78,46. Any ideas where i take the wrong turn? I use 102/YXZ convention. i tried to implement it like described here: Rotate a quaternion by Euler angles input.

  Vector3f retVector;
    Matrix3f rotFromMat, qautRotMatrix;

const auto fromPitch = xFrom*M_PI/360;
const auto fromYaw = zFrom*M_PI / 360;
const auto fromRoll = yFrom*M_PI / 360;



rotFromMat = AngleAxisf(fromRoll,  Vector3f::UnitY())
    * AngleAxisf(fromPitch, Vector3f::UnitX())
    * AngleAxisf(fromYaw,   Vector3f::UnitZ());
Quaternionf fromQuat(rotFromMat);

    fromQuat.normalize();

    fromQuat = fromQuat * AngleAxisf(yTo, Vector3f::UnitY());
    fromQuat = fromQuat * AngleAxisf(xTo, Vector3f::UnitX());
    fromQuat = fromQuat * AngleAxisf(zTo, Vector3f::UnitZ());


    qautRotMatrix = fromQuat.toRotationMatrix();

    retVector = quatRotMatrix.eulerAngles(1, 0, 2);
    retVector *= 360 / M_PI;

    return retVector; 

You didn't gave enough details on how to reproduce this.

But I can tell see two mistakes: * The ratio between degrees and radian is 180/PI and not 360/PI. * Your rotation order is wrong! The left side is rotating the right side:

fromQuat = AngleAxisf(...) * fromQuat;

From the date I can guess you already solve this, I comment here for the new viewers

链接地址: http://www.djcxy.com/p/81866.html

上一篇: Quaternion正在翻转非常类似旋转的标志?

下一篇: 使用特征根据欧拉角旋转四元数