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:
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)))
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 !