0

I am trying to extract the rotation of an object based on these values:

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

I am not quite sure how to do that properly.. I found a few solutions online but none worked for me since all values used on those examples were a bit different from the one above. Does anyone know how to extract that using Python/OpenMaya? I would appreciate any help. Thanks in advance.

Phil
  • 77
  • 3
  • What are those values? I _think_ quaternions would be complex numbers, so are these unpacked values including Cartesian coordinates? – Simon Crowe Dec 18 '21 at 18:46
  • Welcome to [Stack Overflow.](https://stackoverflow.com/ "Stack Overflow") Please be aware this is not a code-writing or tutoring service. We can help solve specific, technical problems, not open-ended requests for code or advice. Please edit your question to show what you have tried so far, and what specific problem you need help with. See the [How To Ask a Good Question](https://stackoverflow.com/help/how-to-ask "How To Ask a Good Question") page for details on how to best help us help you. – itprorh66 Dec 18 '21 at 19:16

1 Answers1

1

The numbers you have specified seem a little strange (and don't really have any context). Anyhow, within Maya, there are a few options for converting a matrix to Euler rotation angles.

  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.

robthebloke
  • 9,331
  • 9
  • 12
  • Hello guys, thanks for you answer. I could confirm this morning that the numbers were totally wrong. Since I never didt that, I was assuming that it was correct.. but after getting some feedback and asking around, I could confirm that it was wrong. I am really I am sorry for wasting your time. Thanks for your help anyway. – Phil Dec 20 '21 at 14:12