How to Combine Transformation Matrices
At a glance
- 1. Choose a convention
Use column vectors and homogeneous coordinates, or state clearly if your convention differs.
- 2. Write each matrix
Represent every rotation, scaling, reflection, shear, or translation as a compatible matrix.
- 3. Multiply in order
For column vectors, the transformation applied first appears on the right.
- 4. Check with a point
Apply the matrices individually to one point and compare with the combined matrix.
Try it: Matrix calculator
Transformation matrices are combined by composition: apply one transformation to a point, then apply the next transformation to the result. The main issue is the order of multiplication.
The convention used here is the standard computer-graphics and linear-algebra convention of column vectors. Under this convention, if is applied first and second, the combined transformation is , not .
The basic rule
Let a point or vector be represented by a column vector . If the first transformation is represented by and the second by , then
and then
Therefore, the combined matrix is
Read the product from right to left: the rightmost matrix acts first.
For several transformations, the same principle gives
where is applied first and is applied last.
Combining linear transformations
In two dimensions, a linear transformation has the form
where is a matrix. For example, a counterclockwise rotation by angle is
Scaling by factors and is represented by
If you rotate first and scale second, the combined matrix is
If you scale first and rotate second, it is instead
These products are generally different because matrix multiplication is not commutative:
Including translations with homogeneous coordinates
A translation cannot be represented by an ordinary matrix acting on , because translation is not a linear transformation. Introduce a third coordinate and write the point as
A translation by is then represented by the matrix
For example, the homogeneous matrices for scaling and rotation are
This lets you combine scaling, rotation, reflection, shear, and translation in one product.
Fully worked example
Suppose a point is transformed in this order:
- Rotate it counterclockwise by .
- Scale the -coordinate by and the -coordinate by .
- Translate it by .
Using homogeneous coordinates, the matrices are
Because the order is rotation, then scaling, then translation, the combined matrix is
First multiply and :
Now multiply by :
Thus every point can be transformed in one step using
For the point ,
Checking step by step gives the same result: rotation sends to , scaling sends this to , and translation sends it to .
Common mistakes
Reversing the order
For column vectors, the first operation is the rightmost factor. If rotation comes first and translation comes second, use , not .
Multiplying entries element by element
Combining matrices means ordinary matrix multiplication. It does not mean multiplying corresponding entries. Each entry of a product is obtained from a row-column dot product.
Treating translations as matrices
A translation requires homogeneous coordinates, usually a matrix in two dimensions and a matrix in three dimensions.
Mixing row and column conventions
Some applications use row vectors, written as . In that convention, the multiplication order is reversed: if is applied first and second, the combined matrix is . Neither convention is wrong, but the vector orientation and order must remain consistent.
Ignoring coordinate systems
A transformation may be described in world coordinates, object coordinates, or coordinates relative to a pivot. Transforming about a pivot often requires several matrices. For example, to rotate about a point , translate by , rotate, then translate by :
Again, the rightmost operation happens first.
A practical verification method
After forming the product, test it on a simple point such as or . Compute the result both ways: apply each transformation separately, and apply the combined matrix once. If the answers differ, check the multiplication order, vector convention, and matrix dimensions.
References
- Introduction to Linear Algebra — Gilbert Strang
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.