1

How can convert a rotation matrix 3x3 into euler angle in Unity?

Is there a built-in function in Unity core?

user2543127
  • 385
  • 10
  • 21
  • 1
    A 3x3 matrix isn't included in Unity, only 4x4 matrices and quaternions. For quaternions, the euler angles can be easily extracted by accessing their property `.eulerAngles`. (e.g. `var rotMatrix = Quaternion.Euler(30, 20, 40); Debug.Log(rotMatrix.eulerAngles);`). So, if you can express your rotation in terms of a quaternion, you can use that. Otherwise you can look at the maths here (http://www.staff.city.ac.uk/~sbbh653/publications/euler.pdf), but remember that Unity does rotation in ZXY order, not ZYX as in the paper. – Maximilian Gerhardt Apr 05 '16 at 19:53
  • 1
    Ok, thanks! But it's possibile to extract euler angles from 4x4 matrix? If not, i have to convert my transformation matrix 4x4 in quaterion matrix and than extract euler angles, right? – user2543127 Apr 05 '16 at 19:56
  • 1
    You could try the code from http://answers.unity3d.com/questions/11363/converting-matrix4x4-to-quaternion-vector3.html to get a `Quaternion` from a `Matrix4x4`. If that helped you, you can also write your own answer. – Maximilian Gerhardt Apr 05 '16 at 21:54

0 Answers0