Hi guys, I'm using an RGB-D Camera to obtain the rotations of a human head from a video live stream. I have tried using the Matrix4x4 struct to create all my matrices for X, Y and Z rotations. However, when I tried to run the program, the rotation angle
did not start from 0 but from an arbitrary angle. I set a 3D point on the human face using the centre point (around the nose) to start the rotation. Also, it seems that I've done wrong because the rotation seemed to perform whenever the person is moving
from one coordinate to another, which is not the head rotation I wanted to do.

Therefore, I'd like to know is there any reference to Matrix that I can use to achieve my purpose?

Thank you.

public static Matrix4x4 MatrixRotationX(float angle)
{
double sin, cos;
sin = Math.Sin(angle) * 180 / Math.PI;
cos = Math.Cos(angle) * 180 / Math.PI;
System.Numerics.Matrix4x4 ret;
ret.M11 = 1.0f; ret.M12 = 0.0f; ret.M13 = 0.0f; ret.M14 = 0.0f;
ret.M21 = 0.0f; ret.M22 = (float)cos; ret.M23 = (float)sin; ret.M24 = 0.0f;
ret.M31 = 0.0f; ret.M32 = (float)-sin; ret.M33 = (float)cos; ret.M34 = 0.0f;
ret.M41 = 0.0f; ret.M42 = 0.0f; ret.M43 = 0.0f; ret.M44 = 1.0f;
return ret;
}

This is the code I referred from the MSDN page.

//To obtain the center point of the face
double face_CentroidX = (face_NewPointXL + face_NewPonitXR) / 2;
double angleX = face_CentroidX;
Rotation.MatrixRotationX((float)angleX);

This is how I implemented my code to get the rotation angle from that particular centroid.