quaternion-to-matrix routine