Proper rotation matrix for quaternions