Prof. Dr. Ulrich Schwanecke
RheinMain University of Applied Sciences
Inner product aka dot product aka scalar product \[ \iprod{ \vec{x} , \vec{y} } = \vec{x} \cdot \vec{y} = \trans{\vec{x}}\vec{y} = \sum_{i=1}^{n} x_i y_i \]
The induced metric measures geometric length \[ \norm{\vec{x}} = \sqrt{ \trans{\vec{x}}\vec{x}} = \sqrt{ \sum_{i=1}^n x_i^2 }\]
Scalar product can measure angle \(\theta\) between two vectors
\[ \mathbf{x}^\top \mathbf{y} = \cos\theta \, \|\mathbf{x}\| \, \|\mathbf{y}\| \quad\Rightarrow\quad \theta = \mathrm{acos}\left( \frac{\mathbf{x}^\top \mathbf{y}}{\|\mathbf{x}\| \|\mathbf{y}\|}\right)\]
Test whether the point \(\vec{p}\) lies in the convex polygon \(\vec{p}_0,\ldots , \vec{p}_5=\vec{p}_0\):
Calculate the edges \(\vec{v}=\vec{p}_{i+1}-\vec{p}_i\) of the polygon
Determine the normal vectors \(\vec{n}_i\)
[\(\vec{n}_i=(-y_i, x_i)^T\) if \(\vec{v}_i=(x_i, y_i)^T\)]
\(\vec{p}\) lies inside the polygon, iff \(\langle \vec{n}_i, (\vec{p}-\vec{p}_i)\rangle <0 \quad\forall\; i = 0,\ldots , n-1\)
The vector product of the vectors \(\vec{v}, \vec{w}\) is given as
\[ \small \begin{pmatrix}v_1 \\ v_2 \\ v_3\end{pmatrix} \times \begin{pmatrix}w_1 \\ w_2 \\ w_3\end{pmatrix} = \begin{vmatrix} \vec{e}_1 & \vec{e}_2 & \vec{e}_3 \\ v_1 & v_2 & v_3 \\ w_1 & w_2 & w_3 \end{vmatrix} = \begin{pmatrix} v_2w_3 - v_3w_2 \\ v_3w_1 - v_1w_3 \\ v_1w_2 - v_2w_1 \end{pmatrix} = \underbrace{ \begin{pmatrix} 0 & -v_3 & v_2 \\ v_3 & 0 & -v_1 \\ -v_2 & v_1 & 0 \end{pmatrix}}_{=:[\vec{v}]_\times} \begin{pmatrix}w_1 \\ w_2 \\ w_3\end{pmatrix} \]
It holds
\(\vec{v}\times\vec{w} = [\vec{v}]_\times \vec{w} = -[\vec{w}]_\times \vec{v}= -\vec{w}\times\vec{v}\)
the vector \(\vec{v}\times\vec{w}\) is orthogonal to the plane defined by \(\vec{v}\) and \(\vec{w}\)
\(\norm{\vec{v}\times\vec{w}}\) equals the area of the parallelogram given by \(\vec{v}\) and \(\vec{w}\)
if \(\vec{v}\times\vec{w} = \vec{0}\in\R^3\) the vectors \(\vec{v}\) and \(\vec{w}\) are collinear
Translate object by \(t_x\) in \(x\) and \(t_y\) in \(y\) \[ \vector{x \\ y} \mapsto \vector{x+t_x \\ y+t_y} \]
Scale object by \(s_x\) in \(x\) and \(s_y\) in \(y\)
(around the origin!) \[ \vector{x \\ y} \mapsto \vector{s_x \cdot x \\ s_y \cdot y} \]
Rotate object by \(\theta\) degrees
(around the origin!)
Rotate point \((x,y) = (r\cos\phi, r\sin\phi)\)
by \(\theta\) degrees around the origin
\[ \begin{eqnarray*} \begin{pmatrix} x\\y \end{pmatrix} &\mapsto& \begin{pmatrix}r \cos\left(\phi+\theta\right) \\ r \sin\left(\phi+\theta\right)\end{pmatrix} \\[2mm] &=& \begin{pmatrix} r \cos\phi \cos\theta - r \sin\phi \sin\theta \\ r \cos\phi \sin\theta + r \sin\phi \cos\theta \end{pmatrix} \\[2mm] &=& \begin{pmatrix}\cos\theta \cdot x - \sin\theta \cdot y \\ \cos\theta \cdot y + \sin\theta \cdot x\end{pmatrix} \\[2mm] &=& \begin{bmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{bmatrix} \cdot \vector{x \\ y} \end{eqnarray*} \]
Rotate object by \(\theta\) degrees
(around the origin!) \[ \vector{x\\y} \mapsto
\matrix{\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta}
\cdot \vector{x \\ y} \]
This can get quite messy!
Represent transformations as matrices!
\[ \mathbf{S}\left(s_x, s_y\right) = \begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix} \]
\[ \mathbf{R}\left(\theta\right) = \begin{bmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{bmatrix} \]
\[ \mathbf{T}\left(t_x, t_y\right) = \begin{bmatrix} ? & ? \\ ? & ?\end{bmatrix} \]
Which transformations can be written as matrices?
VERY useful fact! 👍 VERY-VERY useful! 😍
But we REALLY want to represent translations as matrices!
Points
Each homogeneous vector of the form \(k\cdot (x_1, x_2, x_3)^\top\) with \(k, x_3 \not= 0\) represents the same 2D point \((x_1/x_3, x_2/x_3)^\top\)
Each homogeneous vector of the form \((x_1, x_2, 0)^\top\) represents the 2D vector \((x_1, x_2)^\top\)
Lines
Incidence of points and lines
Two lines with homogenous vectors \(\vec{l}_1\) and \(\vec{l}_2\) intersect in a point with homogeneous coordinate vector \(\vec{p} = \vec{l}_1 \times \vec{l}_2 = [\vec{l}_1]_\times \vec{l}_2\)
The line given by two points with homogenous vectors \(\vec{p}_1\) and \(\vec{p}_2\) is given by the homogeneous coordinate vector \(\vec{l} = \vec{p}_1 \times \vec{p}_2 = [\vec{p}_1]_\times \vec{p}_2\)
\[ \matrix{ s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & 1 } \]
\[ \matrix{\cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1} \]
\[ \matrix{ 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1} \]
Columns of matrix are images of basis vectors!
Very important for performance!
What is the matrix representation?
Any point \(\vec{C}\) on a line is an affine combination \[(1-\alpha)\vec{A} + \alpha\vec{B}\] of its endpoints \(\vec{A}\) and \(\vec{B}\).
Affine transformation \(\mat{M}\) preserves affine combinations \[ \mat{M}\left((1-\alpha)\vec{A} + \alpha\vec{B}\right) \;=\; (1-\alpha)\mat{M}\left(\vec{A}\right) + \alpha\mat{M}\left(\vec{B}\right) \]
Straight lines stay straight lines
Which matrix represents the 2D translation \(\vector{x\\y} \mapsto \vector{x+a \\ y+b}\)?
Which matrix computes the
transformation on the right?
Give the homogenous vector for line through the points \(\vec{x}=(1,2)^\top\) and \(\vec{y}=(3,4)^\top\).
Give the homogenous vector for the intersection of the lines \(x-y+1=0\) and \(x-y-1=0\).