Search code examples
mathmatrixrotational-matrices

Nullifying an angle in a Rotation Matrix


Say I have a Rotation Matrix, which is used to rotate a 3D model. Is it possible to set the yaw of the rotation matrix to zero before applying it to the model?

Regards, Adam.


Solution

  • RotMatrix=R(yaw)*R(pitch)*R(roll)

    to eliminate yaw factor, we can left-multiply this matrix on negative yaw matrix

    RotMatrixNew=R(-yaw)*R(yaw)*R(pitch)*R(roll) = I**R*(pitch)*R(roll) = R(pitch)*R(roll)

    If yaw angle isn't known before, then it could be calculated as

    yaw = ArcTan2(RotMatrix[2][1], RotMatrix[1][1])