Transformation matrix

There are alternative expressions of transformation matrices involving row vectors that are preferred by some authors.

[2][3] Matrices allow arbitrary linear transformations to be displayed in a consistent format, suitable for computation.

For this reason, 4×4 transformation matrices are widely used in 3D computer graphics.

In the physical sciences, an active transformation is one which actually changes the physical position of a system, and makes sense even in the absence of a coordinate system whereas a passive transformation is a change in the coordinate description of the physical system (change of basis).

in functional form, it is easy to determine the transformation matrix A by transforming each of the vectors of the standard basis by T, then inserting the result into the columns of a matrix.

The matrix representation of vectors and operators depends on the chosen basis; a similar matrix will result from an alternate basis.

[4] Yet, there is a special basis for an operator in which the components form a diagonal matrix and, thus, multiplication complexity reduces to n. Being diagonal means that all coefficients

Most common geometric transformations that keep the origin fixed are linear, including rotation, scaling, shearing, reflection, and orthogonal projection; if an affine transformation is not a pure translation it keeps some point fixed, and that point can be chosen as origin to make the transformation linear.

A stretch in the xy-plane is a linear transformation which enlarges all distances in a particular direction by a constant factor but does not affect distances in the perpendicular direction.

Similarly, a stretch by a factor k along the y-axis has the form x' = x; y' = ky, so the matrix associated with this transformation is

If the two stretches above are combined with reciprocal values, then the transformation matrix represents a squeeze mapping:

The reciprocal stretch and compression leave the area invariant.

For rotation by an angle θ counterclockwise (positive direction) about the origin the functional form is

Similarly, for a rotation clockwise (negative direction) about the origin, the functional form is

For shear mapping (visually similar to slanting), there are two possibilities.

As with reflections, the orthogonal projection onto a line that does not pass through the origin is an affine, not linear, transformation.

Parallel projections are also linear transformations and can be represented simply by a matrix.

However, perspective projections are not, and to represent these with a matrix, homogeneous coordinates can be used.

The matrix to rotate an angle θ about any axis defined by unit vector (x,y,z) is[7]

If the 4th component of the vector is 0 instead of 1, then only the vector's direction is reflected and its magnitude remains unchanged, as if it were mirrored through a parallel plane that passes through the origin.

Since text reads from left to right, column vectors are preferred when transformation matrices are composed: If A and B are the matrices of two linear transformations, then the effect of first applying A and then B to a column vector

In other words, the matrix of the combined transformation A followed by B is simply the product of the individual matrices.

Reflection matrices are a special case because they are their own inverses and don't need to be separately calculated.

To represent affine transformations with matrices, we can use homogeneous coordinates.

The latter is obtained by expanding the corresponding linear transformation matrix by one row and column, filling the extra space with zeros except for the lower-right corner, which must be set to 1.

Although a translation is a non-linear transformation in a 2-D or 3-D Euclidean space described by Cartesian coordinates (i.e. it can't be combined with other transformations while preserving commutativity and other properties), it becomes, in a 3-D or 4-D projective space described by homogeneous coordinates, a simple linear transformation (a shear).

a rotation R by an angle θ counter-clockwise, a scaling S with factors

When using affine transformations, the homogeneous component of a coordinate vector (normally called w) will never be altered.

Another type of transformation, of importance in 3D computer graphics, is the perspective projection.

More complicated perspective projections can be composed by combining this one with rotations, scales, translations, and shears to move the image plane and center of projection wherever they are desired.

Effect of applying various 2D affine transformation matrices on a unit square. Note that the reflection matrices are special cases of the scaling matrix.
Affine transformations on the 2D plane can be performed in three dimensions. Translation is done by shearing parallel to the xy plane, and rotation is performed around the z axis.
Comparison of the effects of applying 2D affine and perspective transformation matrices on a unit square.