MEulerRotation::decompose() seems to be buggy.
import math
import maya.OpenMaya as OpenMaya
def _getScaleMMatrix(sx, sy, sz, space = OpenMaya.MSpace.kTransform):
ar = OpenMaya.MScriptUtil()
ar.createFromDouble(sx, sy, sz)
trns = OpenMaya.MTransformationMatrix()
trns.setScale(ar.asDoublePtr(), space)
return trns.asMatrix()
def _getRotationMMatrix(rx, ry, rz):
ar = OpenMaya.MScriptUtil()
ar.createFromDouble(rx, ry, rz)
trns = OpenMaya.MTransformationMatrix()
trns.setRotation(ar.asDoublePtr(), OpenMaya.MTransformationMatrix.kXYZ, OpenMaya.MSpace.kTransform)
return trns.asMatrix()
mmat = OpenMaya.MMatrix()
mmat *= _getScaleMMatrix(1.0, 10.0, 1.0)
mmat *= _getRotationMMatrix(math.radians(30), math.radians(80), math.radians(0))
euler = OpenMaya.MEulerRotation.decompose(mmat, OpenMaya.MEulerRotation.kXZY)
print math.degrees(euler.x), math.degrees(euler.y), math.degrees(euler.z)
It prints 3.30430518016 80.0 0.0, not 30.0, 80.0, 0.0 or equivalent.
No comments:
Post a Comment