I have a rotation matrix like so:

[1, 0, 0] -> right axis (x)
[0, 1, 0] -> up axis (y)
[0, 0, 1] -> look direction (z)

[M11, M12, M13]
[M21, M22, M23]
[M31, M32, M33]

I would like to extract the euler angles from this matrix where yaw is rotation around the y axis, pitch is rotation around the x axis, and roll is rotation around the z axis.

Here is my code so far:

yaw = Atan2(M31, M33);
pitch = -Asin(M32);
roll = Atan2(M21, M22);

The yaw and pitch are computed correctly. The roll, however, is incorrect. How should this 3D rotation matrix be decomposed?

  • $\begingroup$ Be aware that in some special configurations only the sum of two angles can be found, there is an indeterminacy. $\endgroup$ – Yves Daoust Feb 6 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.