- Home /
Problem with rotation order of euler angles when importing MoCap data
I'm currently trying to display MoCap data from a Mocap-Suit in Unity 3D in realtime. The Suit SDK returns euler angles for each captured joint. I hoped that I could just take these Euler Angles and pass them to the appropriate joints in Unity by setting the transform.localEulerAngles attributes with the captured euler angles. This works quite well, but I have some Issus like when moving my foot to the right, the avatar in Unity moves its foot to the left.
First I checked, if the capture SDK uses the same euler angle convention like Unity:
The capture SDKs doc says:
"Rotations are all CCW looking down the axis of rotation (in the minus direction) The order of the Euler angles at each node is z, then x, then y so the complete rotation matrix is YXZ."
Unitys doc says:
"The x, y, and z angles represent a rotation z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order)."
So the order of rotation seems to be the same, except I don't really know what is meant by "rotation matrix is YXZ" and if unity also uses counter clockwise rotation like the sdk. Could that be the problem?
I also checked, if the sdk uses the same definition for its coordinate system as unity:
The capture SDKs doc says:
"The actor will be placed standing up along the positive Z axis with the lowest foot at Z=0, facing down the minus Y axis, with the positive X axis pointing to the actor's right. This is a right handed coordinate system."
As a result of these information the sdk coordinate system looks like that:
The avatar is looking in -y direction and the rotation order of the euler angles is z, x, y.
And thats the coordinate System in Unity:
The avatar is looking in z direction. The z axis in unity is equivalent to the -y axis of the sdk. The same applies for y, z and x, x. As a result of this I have to use the z values of the sdk for my y values in unity, the negated y values from the sdk for my z values in unity and the x values from the sdk for my x values in unity.
After having done this, I think I have one more problem. Unity will now apply the rotation by first rotating around the z axis (which was originally my -y axis in the sdk), than around the x axis (which was originally my x axis) and finally around the y axis (originally the z axis). This means in unity the original sdk axis are rotated in the following order: -y, x, z. Actually thats not what I want to do, as I want to rotate in z, x, y order.
I would really like to know, if my thoughts on that are correct and if yes, what would be a solution to get back to the right rotation order in Unity?
I wondered if you solved your problem? I have the same problem on an animation project and it's proving very difficult to make progress. It would be great if you or another user can advise what to bear in $$anonymous$$d when transferring the data to my animation ready rig. I'm working in $$anonymous$$aya.
Answer by GeorgeTheCableCar · Oct 04, 2016 at 10:18 AM
Well this may be a year late, but for people who run into the same problem- the solution is to use quaternions to modify the rotation directly.
e.g
Object.transform.localRotation =
Quaternion.AngleAxis(AngleZdeg, Vector3.forward) *
Quaternion.AngleAxis(AngleYdeg, Vector3.up) *
Quaternion.AngleAxis(AngleXdeg, Vector3.right);
This would rotate XYZ in that order. Notice that the order is in reverse. This is because of the way unity overloaded the multiplication operator You just have to do whatever order you want in reverse.
Your answer
![](https://koobas.hobune.stream/wayback/20220613200439im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D animation : problem with rotation interpolation 1 Answer
Detecting Opposite Rotations of two Pipes 1 Answer
trying to RotateAround an object around another object using mouse 1 Answer
Quad rotor simulation spin between 180/-180 1 Answer
Instantiated object should be rotated by 90 but it is only 0.7 1 Answer