Fixed a bug when converting a matrix to a quaternion.