GRIM: Fix matrix to quaternion conversion. Fixes #1132