Add method for converting a matrix to a quaternion