KinectManager.ConvertMatrixToQuat C# (CSharp) Method

ConvertMatrixToQuat() private method

private ConvertMatrixToQuat ( KinectWrapper, ori, int joint, bool flip ) : Quaternion
ori KinectWrapper,
joint int
flip bool
return Quaternion
    private Quaternion ConvertMatrixToQuat(KinectWrapper.SkeletonJointOrientation ori, int joint, bool flip)
    {
        Vector3 vZ = Vector3.zero;
        Vector3 vY = Vector3.zero;

        if(ori.confidence > 0.5)
        {
            if(flip)
            {
                // For the spine and waist, we flip y rotation.
                //if(joint <= 4)
                {
                    vZ = new Vector3(ori.m02, -ori.m12, ori.m22);
                    vY = new Vector3(-ori.m01, ori.m11, -ori.m21);
                }
        //				// Everything else, we flip in a way that doesn't break the model (MAGICAL)
        //				else
        //				{
        //					vZ = new Vector3(-ori.m02, ori.m12, -ori.m22);
        //		            vY = new Vector3(ori.m01, -ori.m11, ori.m21);
        //				}
            }
            else
            {
                vZ = new Vector3(-ori.m02, -ori.m12, ori.m22);
                vY = new Vector3(ori.m01, ori.m11, -ori.m21);
            }

            if(vZ.x != 0.0f || vZ.y != 0.0f || vZ.z != 0.0f)
            {
                return Quaternion.LookRotation(vZ, vY);
            }
        }

        return Quaternion.identity;
    }