# 3D 3-axes rotation into 3D 2-axes rotation

Hello everyone and thanks in advance to anyone who'll help me through this !

I am currently working on the Kinect V2 (for XBox One) to interact with an avatar. I'd like to use the rotation quaternion that the SDK 2.0 give for each joint of the Skeleton. My avatar (virtual avatar of NAO robot) communicates through nautical angles, yaw, ptich and roll. There's no problem to convert quaternions into nautical angles, but here's my problem :

Let's take the shoulder as an example of joint; Where the Kinect express the rotation of my shoulder as a 3-axes rotation, I need to convert it into a 2-axes rotation. So for my shoulder I have a [Yaw, Pitch, Roll] from the Kinect, which I want to convert into a [Pitch, Roll] for NAO's avatar

At the beginning, I didn't see the problem; I just ignored the Yaw angle. But I rapidly noticed that the movement was not the same than in the Kinect (and it makes sense).

Can someone help me ? How can I convert a 3D 3-axes rotation into a 3D 2-axes rotation ?

• Are the angles you're talking about absolute or relative to the thing the arm is attached to? I'm having some trouble visualising how the two things you want to convert between differ.
– Anko
Aug 29, 2015 at 18:16
• Yes they are relative. Take a look at the NAO's arm picture. The angles are relative to a "standard position" at 0° yaw and 0° Pitch. If your concerned about the standard positions of the Kinect, it's not a problem, for some joints you have to invert an axis or add a 90° somewhere, but it is easily done. My real problem is to get the right move with NAO using two axes in my rotation Aug 29, 2015 at 23:28
• upload.wikimedia.org/wikipedia/commons/3/3e/… that's the three angles the human shoulder can rotate with. Tha NAO can move with only two of them Aug 30, 2015 at 6:54

What you want to do here is preserve the direction that the upper arm points. So let's first get that direction (relative to the parent bone's space)

localArmDirection = kinectJointQuaternion * neutralArmdirection;


Now that you have a unit vector describing the 3D direction that you want the arm to point (relative to the torso), you can convert it into spherical coordinates to get the corresponding pitch and roll angles.

Here I'll make some assumptions about your torso coordinate system, but these are easy to convert if your conventions are different. Let's say...

• x+ points to the right (ie. out like a T-pose for the right arm, or into the chest for the left arm)
• y+ points straight up
• z+ points forward / ventrally

pitch = atan2(localArmDirection.y, localArmDirection.z)