added conversion from matrix to quaternion