How do you get the translation/rotation part of a matrix?

I’m trying to create an isometry from a Matrix4, but how do I extract the rotation and translation components from the matrix without reading entries manually?

Hi!

You can use:

let isometry: Isometry3<f32> = nalgebra::try_convert(matrix4).expect("The matrix was not an isometry");

However this will perform expensive checks to make sure the given matrix is actually a direct isometry (that is, it does not contain any scaling or reflection). If you are sure your input matrix really represent an isometry and want to avoid those checks for performance reasons, you can use nalgebra::convert_unchecked instead.

Hmm, I should’ve mentioned that I was looking to take the xy translation and z rotation from a Matrix4 and turn it into an Isometry2, not an Isometry3…