Detect a lossy matrix decomposition? I am writing a plugin to export data from 3DS Max. 3DS Max's geometry pipeline is... interesting.

As part of my plugin I decompose a transform matrix into a translation, (quaternion) rotation &amp; scale using an inbuilt function.
This of course does not always work, such as when a shear is present.

Max does have an affine decomposition function, but I don't want to use that because the resulting components do not all have an analogue in the destination application.

What I'd like to do, is detect when the decomposition is lossy, so I can bake the geometry for the object which uses it, before transmitting it.

How can I determine, either before or after, whether a matrix TRS decomposition is exact?
You can detect a matrix that can't be decomposed in TRS form by taking its 3×3 upper-left submatrix, interpreting its columns as vectors, and dotting them together in all combinations (1 with 2, 2 with 3, and 1 with 3). For a TRS matrix, the three dot products should all be zero, i.e. the column vectors should be orthogonal to each other. If any of the dot products are nonzero (beyond some epsilon to account for roundoff error) then the matrix is not decomposable as TRS.

This derives from the property that a rotation matrix is an orthogonal matrix, i.e. its column vectors form an orthonormal basis. When you multiply the rotation by a scaling matrix, the column vectors may no longer be unit vectors, but they should still be orthogonal. And the translation part doesn't affect the rotation-scaling part.