Rotation angle from a camera using MSDN Rotation library RRS feed

  • Question

  • 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;                

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

    Monday, April 16, 2018 7:58 AM

All replies

  • Hello StevenWong1995,

    Check the below formulas of rotation matrices.

    Rotation Matrix given angle and point in X,Y,Z

    Hope this would be helpful.

    Best Regards,

    Neil Hu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Tuesday, April 17, 2018 2:16 AM