# Different euler rotation from same Matrice between Blender and Maya

My problem is the following: I start from the same matrix between Blender and Maya and I want to get the euler rotation in degrees of this matrix. The problem is that I don’t get the same results at all between Blender and Maya, even crossing all possible combinations of rotation order (XYZ, XZY, YXZ, etc). Very important, I have to keep the code in Maya as it is, the goal is to transpose the code that is on Maya to Blender and get the same result from the same matrix.

So I wanted to know how the euler rotation was calculated from the matrix on Blender and on Maya so that I could adapt on Blender.

Here is the test code:

Maya :

from __future__ import print_function
from maya.cmds import *
from math import asin, sin, cos, pi, acos, atan2, degrees, sqrt
import maya.mel
import pymel.core.datatypes as dt

matTest = dt.Matrix()
matTest.a00 = 0.8486
matTest.a01 = -0.0541
matTest.a02 = 0.5262
matTest.a03 = 0

matTest.a10 = 4.4218
matTest.a11 = -4.7339
matTest.a12 = -7.6182
matTest.a13 = 0

matTest.a20 = -0.2903
matTest.a21 = -0.8792
matTest.a22 = 0.3778
matTest.a23 = 0

matTest.a30 = 0
matTest.a31 = 0
matTest.a32 = 0
matTest.a33 = 1

print(matTest.formated())
transformation_matrix = dt.TransformationMatrix(matTest)
print(transformation_matrix.formated())
transformation_matrix.reorderRotation(dt.TransformationMatrix.kZXY)
print(transformation_matrix.formated())
rotation = transformation_matrix.getRotation()
print(str(degrees(rotation.x)) + ", " + str(degrees(rotation.y)) + ", " + str(degrees(rotation.z)))


Blender:

import bpy
import bpy_extras
import math
import mathutils
from math import degrees, radians, cos, sin

orderRot = 'ZXY'
mFinal = mathutils.Matrix([
[0.8486, -0.0541, 0.5262, 0.0],
[4.4218, -4.7339, -7.6182, 0.0],
[-0.2903, -0.8792, 0.3778, 0.0],
[0.0, 0.0, 0.0, 1.0]
])
print(mFinal)

euler = mFinal.to_3x3().to_euler(orderRot)
print("EULER ROT  : " + str(degrees(euler.x)) + ", " + str(degrees(euler.y)) + ", " +
str(degrees(euler.z)))

#print(mFinal.to_3x3().normalized().to_euler())
#print(mFinal.to_3x3().normalized().to_euler(orderRot))


The result from the maya script and expected is the following : Euler rotation in degrees : (x= -61.5445699885, y = 142.460065238, z = -173.480241609)

If anyone got any idea ? Thanks !

• After a quick check Maya uses Y axis as "Up" so you may have to invert Y and Z in all matrices. My 2 Cents May 14 at 11:03
• Already tried to multiply with a matrice to invert Y and Z axis in the initial matrice, but it doesn't work :/ May 14 at 12:54
• Does Maya use row or column matrix? Simple test make a translation matrix. Is the location in last row or column? May 14 at 13:31
• And what is the expectation here? Decomposing matrix in blender (0, 0, 0) location, [-37.57330775634702, -26.185184796570315, -50.13446618720194] XYZ Euler rotation (in degrees) and scale (-4.511841297149658, -4.815155982971191, -7.64569091796875) .. what is the expected result? May 14 at 13:40
• Thanks you for your answer. The expected result is the result from the code I shared from Maya : (x= -61.5445699885, y = 142.460065238, z = -173.480241609) The translate in world matrix of an object in Maya is in the last row May 14 at 13:54