Newer
Older
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
.. _transformation-geometry-ressources-page:
=================
Transformations
=================
Transformation matrices
-----------------------
To transform a vector, we multiply the vector with a transformation matrix
.. math::
\begin{pmatrix} x' \\ y' \end{pmatrix} = \mathbf{T} \begin{pmatrix} x \\ y \end{pmatrix}
Usual transformation matrices in 2D are
.. math::
\begin{align}
\mathbf{Id} &= \begin{bmatrix}
1 & 0 \\
0 & 1
\end{bmatrix} \\[1em]
\mathbf{Scale}(s_x, s_y) &= \begin{bmatrix}
s_x & 0 \\
0 & s_y
\end{bmatrix} \\[1em]
\mathbf{Rotation}(\theta) &= \begin{bmatrix}
\cos\theta & \sin\theta \\
-\sin\theta & \cos\theta
\end{bmatrix} \\[1em]
\end{align}
For translation and affine transformation, we must introduce the concept of homogeneous coordinate
which add a virtual third dimension:
.. math::
\mathbf{V} = \begin{bmatrix}
x \\
y \\
1
\end{bmatrix}
Then the translation and affine transformation matrix are expressed as:
.. math::
\begin{align}
\mathbf{Translation}(t_x, t_y) &= \begin{bmatrix}
1 & 0 & t_x \\
0 & 1 & t_y \\
0 & 0 & 1
\end{bmatrix} \\[1em]
\mathbf{Generic} &= \begin{bmatrix}
r_{11} & r_{12} & t_x \\
r_{12} & r_{22} & t_y \\
0 & 0 & 1
\end{bmatrix}
\end{align}
To compose transformations, we must multiply the transformations in this order:
.. math::
\mathbf{T} = \mathbf{T_n} \ldots \mathbf{T_2} \mathbf{T_1}
Note the matrix multiplication is not commutative.