2D transformation matrix order?

2.3k Views Asked by At

Rotate a triangle with vertices (2, 1). (4. 1). (3, 3) by 90 degrees (clock wise) and then Translate it by Tx 4 and Ty 3 and finally rotate it by 30 degrees (anti-clock wise). (cos90=0, sin90 1. cos 30 = 0.866, sin30 =0.5)

T1 is Rotation with 90 T2 is Translation T3 is Rotation with 30

What is correct order of transformation matrix to multiply the metrix?

T3 T2 T1 or T1 T2 T3?

Should i follow the order given by the question or reverse order?

2

There are 2 best solutions below

1
On BEST ANSWER

T3@T2@T1@vertices since the T1 matrix will be applied first. Here is the representation with parentheses to emphasize the order of operations:

T3@(T2@(T1@vertices))

P.S. the @ symbol is how you multiply matrices in python.

1
On

The order depends on whether you’re working with column vectors and left-multiply by a matrix to transform them (the common mathematical convention), or with row vectors that get right-multiplied by transformation matrices.

A simple way to remember the correct order of multiplication is that when you compose transformations, each successive transformation is applied to the result of the previous one—the chain of multiplications grows away from the thing being transformed. Thus, using the column vector convention, if you want to transform a vector $\mathbf v$ first by $T_1$ and then by $T_2$, you would first compute $T_1\mathbf v$ and then $T_2(T_1)\mathbf v = (T_2T_1)\mathbf v$. With three transformations, it would be $T_3(T_2(T_1\mathbf v)) = (T_3T_2T_1)\mathbf v$. If we’re instead working with row vectors, the chain of multiplications would grow to the right instead of the left as above.