Looking at a matrix with elements numbered like this:
[ a00 a01 a02 a03 ]
[ a10 a11 a12 a13 ]
[ a20 a21 a22 a23 ]
[ a30 a31 a32 a33 ]
- A scaling transform has values other than 1.0 in elements
a00
, a11
and/or a22
.
- A translation matrix has values other than 0.0 in elements
a03
, a13
and/or a23
.
If those are the only types of transformations you expect, all other values must match the identity matrix.
It's relatively rare to have non-identity values in the last row, unless you're dealing for example with projection matrices. If the matrix in question could potentially be of that form, you'll have to test for:
a30 == 0.0
a31 == 0.0
a32 == 0.0
a33 == 1.0
Other than that, you'll just have to test the non-diagonal elements of the upper-left 3x3 matrix to be zero:
a01 == 0.0
a02 == 0.0
a10 == 0.0
a12 == 0.0
a20 == 0.0
a21 == 0.0
Any of these values being non-zero would introduce some form of rotation/skew.
As always, be careful about comparing floating point values for equality. The values above will be exactly 0.0 if they were never set to anything else. But if the matrix is the result of some form of computation, you may have to test for the values being smaller than a small constant, instead of for exactly 0.0.
When testing the matrix values, be mindful about your matrix being stored in row- or column-major order. For example, if you matrix elements are stored in an array, element a03
will be at index 3 in row-major order, and at index 12 in column-major order.