# Valid transformation matrix

Does somebody know how to determinate if a given matrix is a valid homogenous transformation matrix ?

Perhaps by testing the invert matrix and trying to decompose it…

Thanks.

Off the top of my head, the 3x3 top left part should consist of 3 vectors that are orthogonal to each other (that is, multiplied they give 0), and the bottom row should be 0,0,0,1.

Quoted from the Redbook-

Homogeneous Coordinates
OpenGL commands usually deal with two- and three-dimensional vertices, but in fact all are treated internally as three-dimensional homogeneous vertices comprising four coordinates. Every column vector (x, y, z, w)T represents a homogeneous vertex if at least one of its elements is nonzero. If the real number a is nonzero, then (x, y, z, w)T and (ax, ay, az, aw)T represent the same homogeneous vertex. (This is just like fractions: x/y = (ax)/(ay).) A three-dimensional euclidean space point (x, y, z)T becomes the homogeneous vertex with coordinates (x, y, z, 1.0)T, and the two-dimensional euclidean point (x, y)T becomes (x, y, 0.0, 1.0)T.
As long as w is nonzero, the homogeneous vertex (x, y, z, w)T corresponds to the three-dimensional point (x/w, y/w, z/w)T. If w = 0.0, it corresponds to no euclidean point, but rather to some idealized “point at infinity.” To understand this point at infinity, consider the point (1, 2, 0, 0), and note that the sequence of points (1, 2, 0, 1), (1, 2, 0, 0.01), and (1, 2.0, 0.0, 0.0001), corresponds to the euclidean points (1, 2), (100, 200), and (10000, 20000). This sequence represents points rapidly moving toward infinity along the line 2x = y. Thus, you can think of (1, 2, 0, 0) as the point at infinity in the direction of that line.

OpenGL might not handle homogeneous clip coordinates with w < 0 correctly. To be sure that your code is portable to all OpenGL systems, use only nonnegative w values.

Hope this helps

My problem is that this following matrix:
[ 1 0 0 0]
[ 0 0 1 0]
[ 0 -2 0 0]
[ 0 0 0 1]
give the following decomposition (using my matrix tools):
Position = 0 0 0
Orientation = -1 0 0 1.5708
Center = 0 0 0
Scale = 1 1 2
ScaleOrientation = 0 0 1 0
but the reprocessed matrix from the last decomposition (always using my matrix tools):
[ 1 0 0 0]
[ 0 -4.37114e-008 2 0]
[ 0 -1 -8.74228e-008 0]
[ 0 0 0 1]

!! Not the same.

every 4x4 matrix is a valid transformation matrix, or which properties do you think makes a 4x4 matrix a valid tranformation matrix

I use the source code of Ken Shoemake and Tom Duff. Matrix Animation and Polar Decomposition. Proceedings of Graphics Interface 1992. GEM IV http://www.acm.org/tog/GraphicsGems/. as following:

void MyMatrix::decompose(vector3f& pTranslation, rotation& pRotation, vector3f& pScale, rotation& pScaleOrient)
{
AffineParts lAffineTransforms;
HMatrix lKenMatrix;
VrMat4f_2HMatrix(myMatrixData, lKenMatrix);

decomp_affine(lKenMatrix, &lAffineTransforms);

HVect_2Vec3f(lAffineTransforms.t, pTranslation);
pRotation.setQuaternion((VrFloat*)&lAffineTransforms.q);
pRotation.invert();
HVect_2Vec3f(lAffineTransforms.k, pScale);
pScale.scale(lAffineTransforms.f);
pScaleOrient.setQuaternion((VrFloat*)&lAffineTransforms.u);
pScaleOrient.invert();
}

And I would like to know if somebody knows a bug about this code…because I don’t really undestrand what it was done in the decomp_affine() function.