0

我正在尝试根据这些值提取对象的旋转:

[ 0.00000000, 0.00000000, 0.00000000,
0.33333334, -0.53828228, 0.00000000,
0.66666669, -1.07656455, 0.00000000,
1.00000000, -1.61484683, 0.00000000 ]

我不太确定如何正确地做到这一点。我在网上找到了一些解决方案,但没有一个对我有用,因为这些示例中使用的所有值都与上面的值有点不同。有谁知道如何使用 Python/OpenMaya 提取它?我将不胜感激任何帮助。提前致谢。

4

1 回答 1

1

您指定的数字似乎有点奇怪(并且实际上没有任何上下文)。无论如何,在 Maya 中,有几个选项可以将矩阵转换为欧拉旋转角。

  1. Construct an MTransformationMatrix (one of the Maya API classes) and provide the matrix in question to the constructor. The eulerRotation() method will return the values (although you may be limited to an XYZ rotation ordering?)

  2. Create a transform node. Specify the rotation-order you want to use by setting the rotation order flag on the node (e.g. xyz, zyx, etc). Use cmds.xform to set the matrix for the transform. Now just use cods.getAttr to read the rotation angles.

  3. Call: MEulerRoation MEulerRoation::decompose(const MMatrix &matrix, RotationOrder ord), passing in the matrix, and the desired rotation order.

于 2021-12-20T03:33:39.793 回答