# Combinations of transformations

← Back: Homogeneous coordinates |
Overview: Transformations |
Next: Inverse transformation → |

In the previous subarticle homogeneous coordinates and transformation matrices for translation and rotation around the three axes are introduced:

These transformation matrices can be combined by multiplying them.

Consider the following transformation matrix that corresponds to the multiplication of several single transformation matrices (also denoted with for simplification):

Combinations of transformations are always applied from right to left. So in the example case, is applied first. Then on this result, transformation is applied and so on. The left transformation matrix is finally multiplied with the result of all the previous transformations.

As already stated for multiplication of matrices, different multiplication orders lead to different results. If only translations are regarded, the order does not matter, because translation is actually vector addition and vector addition is commutative. Rotation however depends on the current input coordinates. Descriptively seen, rotation is always applied around the origin of the global coordinate system or around an axis intersecting with the origin, respectively. So the rotational part is depending on the respective current coordinates. Different orders of transformations result in different input coordinates for each transformation.

The following example shows descriptively as well as computationally, that the order of transformations is important (see figure on the right). Consider a local coordinate frame positioned in the origin, whose axes are oriented parallel to the global coordinate axes. The related initial position vector is a zero vector. A translation matrix and a rotation matrix are to be applied to this local frame. So two different orders of the two transformations are possible.

The upper three subfigures on the right show the first case. The local frame is first rotated around the x-axis and then translated on the z-axis. The result is shown in the top right subfigure. Computationally is first pre-multiplied with and then pre-multiplied with :

The lower three subfigures on the right show the second case. The local frame is first translated on the z-axis and then rotated around the x-axis. The result is shown in the lower right subfigure. Computationally is first pre-multiplied with and then pre-multiplied with :

As you can see from the transformed vectors and , the transformation order influences the result. In the example there is only one rotation applied. So the orientation of the local frame is the same in both cases. But if there is more than one rotation applied, the resulting orientation differs as well.

The general homogeneous transformation matrix , introduced for homogeneous coordinates, consists of a rotation matrix and a translation vector. As shown in the subarticle, multiplication of with a vector corresponds to rotating the coordinates first and then adding the translation vector. Written as product of homogeneous transformation matrices, equals: (where *axis* is either , or )

As explained for Homogeneous coordinates applying a homogeneous transformation matrix is equivalent to first multiplying with the corresponding rotation matrix and then adding the translation vector:

Assume the composed transformation . So is to be applied on the result of the first transformation, which leads to:

Thus the multiplication of two general homogeneous transformation matrices is defined as follows:

#### Applet

The following applet can be used to test some combinations of different transformations and see the results in a three-dimensional visualization.

Example: Combinations of transformations
This example is taken from pages 3-34 and 3-35 of the robotics script. The transformation of the object frame with respect to the reference frame is defined as follows:
When is applied (see figure on the right), the input coordinates are first translated by along the y-axis and then rotated by 90 degrees around the x-axis. Then again a translation by on the z-axis is applied and finally the coordinates are rotated by 90 degrees around the y-axis. The four transformation matrices are multiplied to obtain the combined transformation matrix (for further intermediate steps have a look in the script on page 3-35): The above combined matrix corresponds to the four single transformation steps applied in the designated order. As can be seen in the lower right subfigure, the resulting coordinates of the local frame correspond to the translation vector within the combined matrix. The axes of the coordinate frame are oriented like the vectors , and within the matrix. |