How to get X,Y,Z rotation using for kinect 2 in windows?

So, i´ve been trying to accoplish this effect:

That´s is basically: knowing the angles of rotation in X,Y and Z of one joint.

I have a kinect 2.

The only addon that i´ve found that work with the kinect 2 in openframeworks is : https://github.com/elliotwoods/ofxKinectForWindows2
done by @elliotwoods .

Now the addon has two functions for knowing the rotation ( i think that is what these functions are for but don´t really know for certain) wich are :

GetOrientation() wich returns a Quarternion and getRawJointOrientation() wich returns a _JointOrientation type.

then.

When I acces to the X,Y and Z of these objects i get data i don´t understand, numbers that goes from -0.1 to 0.1. Tryed to map each number to -180,180 wich are the degrees that are posible to map with, but the data is still not clear, The number do now work as espected.

-Is something that im missing in the way that im using those functions?
-Is there any easy way to make this effect?
-Does someone done something familiar?

Any kind of help is greatly apreciatted.

You need to look into quaternions
They work differently than XYZ rotations
I’m not an expert at that, generally i just convert to ofMatrix4x4 and apply that transform.
To convert, I think th code is auto transform = ofMatrix4x4(quaternion)

Okay . . .im not sure how Quaterniorns work. What should i do after I make :

auto transform = ofMatrix4x4(quaternion) ?

I´ve tryed :

ofQuaternion  o = body.joints[JointType_Head].getOrientation();
auto transform = ofMatrix4x4(o);

So im suppposed to get X,y,z rotation from the variable “transform” ? or… what?

once you have the transform, then you can do :

auto orientation = body.joints[JointType_Head].getOrientation();
auto transform = ofMatrix4x4(orientation);
ofPushMatrix();
{
    ofMultMatrix(transform);

    // do your drawing here
    head.draw();
}
ofPopMatrix();

Then the head object will be drawn with the rotation applied

Hmm for some reason it doesn´t seem to be working.

First I declared :

ofMatrix4x4 mat;

in .h file.

The update function :

auto bodies = kinect.getBodySource()->getBodies();
	bool isbodytrack = false;
	for (auto body : bodies) {
		if (body.tracked) {
			isbodytrack = true;
			manoder_pos = body.joints[JointType_HandRight].getPositionInDepthMap()*1.1;
			manoizq_pos = body.joints[JointType_HandLeft].getPositionInDepthMap()*1.1;
			pecho = body.joints[JointType_SpineMid].getPositionInDepthMap()*1.1;
			cabeza = body.joints[JointType_Head].getPositionInDepthMap()*1.1;
			ofQuaternion  o = body.joints[JointType_Head].getOrientation();
			//float a = o.getEuler();
			mat = ofMatrix4x4(o);
			//_JointOrientation kl = body.joints[JointType_SpineMid].getRawJointOrientation();
			/*rotx = 1;
			roty = o.getEuler().y;
			rotz = o.getEuler().z;*/
		}
		
	}

This is what im doing in the drawing function :

ofPushMatrix();
		{
		ofMultMatrix(mat);
		ofTranslate(cabeza.x, cabeza.y);
		/*ofRotateX(rotx);
		ofRotateY(roty);
		ofRotateZ(rotz);
		*/
		ofSetColor(200, 90, 255);
		ofCircle(0, 0, 40);
		}
ofPopMatrix();

Im trying to see if it works with just a circle.
I´ve tryed puting ofTranslate and without ofTranslate.

Im not geting no rotation or translation if use ofMultMatrix(mat). Is like is not doing anything

I didnt get the orientation of the head. All Values staying at 0.

ofQuaternion q = body.joints[JointType_Head].getOrientation();

Any ideas? If i do this for the neck it is fine, also the euler conversion of the quaternion.