Search code examples
rotationquaternions

How do I modify a quaternion such that the Euler rotation on one axis is zero?


I've got two nodes, and I know the rotation of only one of them.

I want to apply the rotation of node 1 to node 2, but with one axis zeroed out (in Euler terms).

How?


Solution

  • Never mind, I figured it out.

    e.g. For x axis:

    double xRot = -(myQuat.ToEuler().x)
    Quat qDiff = Quat(sin(xRot / 2.0), 0, 0, cos(xRot / 2.0)).Normalize()
    Quat myQuatZeroX = myQuat * qDiff