# Why composite transformations are multiplied to the right side?

I have seen that many composite transformations have the later transformation multiplied to the right side of the matrix. Say I have matrix an existing transformation matrix $\mathbf{M}$ and then other transformation matrices $S$ for scaling, $T$ for translation, $R$ for rotation. I want to do a rotation first then translation then scaling, I have to do this: $\mathbf{M}(R)(T)(S)=\mathbf{M^'}$. Now the final matrix $\mathbf{M^'}$ has the composite transformations in the sequence that I could use it to transform vectors with $\mathbf{M^'}\vec{x}=\vec{x^{'}}$.

But the question is why are transformations multiplied to the right side of the matrices and how can I prove that it has to be multiplied to the right side? What would the meaning be if I had multiplied them to the left side instead as $(S)(T)(R)\mathbf{M}=\mathbf{M^'}$?

Sometimes, I have this tendency to multiply to the left because in row elementary operations, the matrices are multiplied to the left.

-
Transformations are usually applied to points (vectors). Whichever of the orders is appropriate depends on whether the system is using row or column vectors... – J. M. Sep 1 '11 at 15:39
In our usual system that we use when 'writing on paper', in which order do we usually use for composite transformations? So can I say that multiplying the transformations on the right side means that the system is using column vectors? – xenon Sep 1 '11 at 15:48
Transformations are not "multiplied"; transformations are applied. Usually, we write functions on the left of the argument (not always, and in some branches of math it is more common to write them on the right), so transformations are written down the same way we write any function: on the left, e.g., $T(\mathbf{x})$. However, in the case of vector spaces there is a natural identification of transformations with matrices which makes "apply the transformation" correspond to "multiply by the matrix". If you want the latter to be written like functions, you need to use column vectors. – Arturo Magidin Sep 1 '11 at 16:01
If, say, I had some point $\mathbf p$ and wanted to rotate (with, say, the rotation matrix $\mathbf Q$) and then scale (with, say, the rotation matrix $\mathbf D$): if $\mathbf p$ was represented as a column, the sequence is $\mathbf D\mathbf Q\mathbf p$, and if $\mathbf p$ was a row, then I should be doing $\mathbf p\mathbf Q\mathbf D$. (Remember that $(\mathbf A \mathbf B)^T=\mathbf B^T \mathbf A^T$.) – J. M. Sep 1 '11 at 16:05
Just to reiterate, so the natural way when written on paper for $T(\vec{x})$, if I wanted Rotation->Translation->Scale, it is $(S)(T)(R)M\vec{x}=M^'\vec{x}$ , is this right? And in this case, I'm using the column vectors as what J.M. mentions. If a particular system uses row vectors instead, say in OpenGL, then it'll have to take the transpose of the equation to become $((S)(T)(R)M\vec{x})^T=(M^{'}\vec{x})^T \Rightarrow \vec{x}^TM^T(R)^T(T)^T(S)^T=\vec{x}^T(M^{'})^T$, am I right? But this wouldn't be $T(\vec{x})$ any more since the now $\vec{x}$ is on the left side of $(M^{'})^T$. – xenon Sep 1 '11 at 16:38

Like Yoda says, "There is no why." There is no rhyme or reason to it. Mathematics is laced with a hodge-podge accumulation of inconsistent conventions that often make learning and doing higher math as cumbersome as learning and doing arithmentic with Roman numerals!

Somewhere along the line, someone defined matrix multiplication as, $C(i,j)=\sum_{k}A(i,k)B(k,j)$, when it could just as well have been defined as

$C(i,j)=\sum_{k}A(i,k)B(j,k)$,

$C(i,j)=\sum_{k}A(k,i)B(k,j)$,

$C(i,j)=\sum_{k}A(k,i)B(j,k)$,

$C(i,j)=\sum_{k}A(j,k)B(k,i)$,

$C(i,j)=\sum_{k}A(j,k)B(i,k)$,

$C(i,j)=\sum_{k}A(k,j)B(k,i)$, or

$C(i,j)=\sum_{k}A(k,j)B(i,k)$.

Someone else decided that the the composition of $a$ and $b$ should be written as $a*b$. Someone else decided that this was inconsistent and wrote the composition of $a$ and $b$ as $b*a$, when he could just as well have redefined matrix multiplication!

Conventions are not written in stone. If you don't like them, make up your own. That's what I do. For the composition of two permutations $a$ and $b$, expressed as row vectors in APL (A Programming Language), I write $c\leftarrow a$[$b$] and APL assigns the result of the composition to the variable $c$. I just use the same notation, replacing the $\leftarrow$ with an =. It turns out that the ] is actually redundant, so $a$[$b$ is just a rewrite of $a$*$b$.

If $A$, $B$, and $C$ are the corresponding matrices that represent these permutations, I write $C$=$AB$, where $AB$ is just the standard multiplication of $A$ and $B$. Problem solved.

How about an example? Consider two permutations in $S_4$, 2431 and 3214:

2431[3214]=3421

3214[2431]=2413

Let's see what happens when we multiply the corresponding matrices from the irreducible representation of $S_4$. These matrices permute the vertices of a tetrahedron at the $(x,y,z)$ coordinates $(6,4,3)$, $(-6,4,3)$, $(0,-8,3)$, and $(0,0,-9)$ among themselves. Making a matrix with these coordinate as the columns, we get:

$\begin{array}{rrrr} 6 & -6 & 0 & 0\\ 4 & 4 & -8 & 0\\ 3 & 3 & 3 & -9 & \\ & \\ & \\ & \\ & \end{array}$

Multiplying this matrix from the left by the representation matrix for 2431, we get:

$\begin{array}{rrrlrrrrlrrrr} -1/2 & -1/4 & -2/3 & & 6 & -6 & 0 & 0 & & -6 & 0 & 0 & 6\\ 1/3 & 5/6 & -4/9 & \times & 4 & 4 & -8 & 0 & = & 4 &0 & 4 & -8\\ 1 & -1/2 & -1/3 & & 3 & 3 & 3 & -9 & & 3 & -9 & 3 & 3\\ & \\ & \\ & \\ & \\ & \end{array}$

Multiplying the same matrix from the left by the representation matrix for 3214, we get:

$\begin{array}{rrrlrrrrlrrrr} 1/2 & -3/4 & 0 & & 6 & -6 & 0 & 0 & & 0 & -6 & 6 & 0\\ -1 & -1/2 & 0 & \times & 4 & 4 & -8 & 0 & = & -8 & 4 & 4 & 0\\ 0 & 0 & 1 & & 3 & 3 & 3 & -9 & & 3 & 3 & 3 & -9\\ & \\ & \\ & \\ & \\ & \end{array}$

Multipying the representation matrices in the order 2431 $\times$ 3214, we get:

$\begin{array}{rrrlrrrlrrr} -1/2 & -1/4 & -2/3 & & 1/2 & -3/4 & 0 & & 0 & 1/2 & -2/3 \\ 1/3 & 5/6 & -4/9 & \times & -1 & -1/2 & 0 & & = -2/3 & -2/3 & -4/9 \\ 1 & -1/2 & -1/3 & & 0 & 0 & 0 & & 1 & -1/2 & -1/3 \\ & \\ & \\ & \\ & \\ & \end{array}$

...which is the represntation matrix for the permutation 3421:

$\begin{array}{rrrlrrrrlrrrr} 0 & -1/2 & -2/3 & & 6 & -6 & 0 & 0 & & 0 & 0 & -6 & 6\\ -2/3 & -2/3 & -4/9 & \times & 4 & 4 & -8 & 0 & = & -8 & 0 & 4 & 4\\ 1 & -1/2 & -1/3 & & 3 & 3 & 3 & -9 & & 3 & -9 & 3 & 3\\ & \\ & \\ & \\ & \\ & \end{array}$

...just as we wanted. You can check for yourself that multiplying the matrices in the opposite order gives you a matrix for the representation of the permutation 2413, as given at the beginning of this example - unless I have made some typing error here; this is VERY tedious!

-
"There is no rhyme or reason to it." - not even wrong, this one. We use definitions that are convenient to use, nothing more. Conventions are indeed not written in stone, but we do use the ones that are (wait for it...) convenient to use for further work. – J. M. Sep 2 '11 at 8:04

Sometime one has to left-multiply, sometimes one has to right-multiply. This really depends.

Prerequisites:

You are performing scaling, rotation, and translation. So let us assume we have linear point transformation of the general form:

$$\mathtt T = \left[ \begin{array}{cc} s\mathtt R & \mathbf t \\ \mathtt O& 1\end{array} \right]$$ which first rotates a point by $\mathtt R$ , then scales it by $s$ and then adds the translation $\mathbf t$:

$$\mathtt T \cdot \left( \begin{array}{c} \mathbf x \\ 1\end{array} \right) = \left[ \begin{array}{c} s(\mathtt R\cdot \mathbf x) + \mathbf t \\ 1\end{array} \right]$$

(Note that rotation and scaling commutes: $s(\mathtt R\cdot \mathbf x)=\mathtt R(s\cdot \mathbf x)$)

From now on we will assume that all points $\mathbf y$ are homogenous points ($\mathbf y= (\mathbf x, 1)^\top$).

Mind the reference frames: In order to make it clear whether you need a left or right multiplication, it is important to highlight in which reference frame your points are!

Let us assume, we have points $\mathbf y_a$ in reference frame $a$, and you want to transform them into reference frame $b$, you do

$$\mathbf y_b = \mathtt T_{ba} \mathbf y_a$$ where $\mathtt T_{ba}$ is a transformation to $b$ from $a$. Note that the indices must match!

Now, let us look at a more complicated example. One might be interested in:

$$\mathbf y_a = \mathtt T_{ab}\mathtt T_{bc}\mathtt T_{cd}\mathbf y_d$$

Further, let's assume that we receive the poses in order (First $\mathtt T_{ab}$, then $\mathtt T_{bc}$...).

We would calculate in an algorithm:

$\mathtt T_{ai} := \mathtt T_{ab}$

(thus, $i=b$)

$\mathtt T_{ai} := \mathtt T_{ai}\cdot \mathtt T_{bc}$

(now, $i=c$)

$\mathtt T_{ai} := \mathtt T_{ai}\cdot \mathtt T_{cd}$

($i=d$)

Thus, we right-multiplied and $\mathtt T_{ai}$ means now $\mathtt T_{ad}$, the transformation from $d$ to $a$. Finally, we can transform our points:

$$\mathbf y_a := \mathtt T_{ad} \mathbf y_d$$

However, if one really wants to left-multiply, this is possible too! Note that $\mathtt T_{ia}=\mathtt T_{ai}^{-1}.$ Thus, we can do:

$\mathtt T_{ia} := \mathtt T_{ab}^{-1}$

($i=b$)

$\mathtt T_{ia} := \mathtt T_{bc}^{-1} \mathtt T_{ia}$

($i=c$)

$\mathtt T_{ia} := \mathtt T_{cd}^{-1}\mathtt T_{ia}$

($i=d$)

Thus, we have $\mathtt T_{ia} = \mathtt T_{da}$, and therefore we can transfrom the point from $d$ to $a$ using the inverse:

$$\mathbf y_a := \mathtt T_{da}^{-1} \mathbf y_d$$

-