GAMES101-02 Linear Algebra
Dependencies
- Basic mathematics: Linear algebra, calculus, statistics
- Basic physics: Optics, Mechanics
- Misc: Signal processing, Numerical analysis
- a bit of aesthetics
Vectors
Doc(scalar) Product
\[ \begin{split} \vec{a}\cdot\vec{b}&=||\vec a||||\vec b||cos\theta\\ cos\theta&=\hat a\cdot\hat b\\ \vec{a}\cdot\vec{b}&=\begin{pmatrix} x_a\\ y_a\\ z_a \end{pmatrix}\cdot\begin{pmatrix} x_b\\ y_b\\ z_b \end{pmatrix}=x_ax_b+y_ay_b+z_az_b \end{split} \]
- Find angle between two vectors (e.g. cosine of angle between light source and surface)
- Finding projection of one vector on another
\(k\) Measure how close two directions are
\[ \begin{split} \vec{a}\cdot\vec{b}&=||\vec b_\perp||||\vec a|| \\ k&=\parallel\hat b_\perp \parallel=\parallel\hat b \parallel cos\theta\\ \hat b_\perp&=k \hat a \end{split} \]
Decompose a vector \(\hat b=(\hat b-\hat b_\perp)+\hat b_\perp\)
Determine forward/backward(k>0 or k<0>)
Cross Product
- Cross product is orthogonal to two initial vectors
- Direction determined by right-hand rule
- Useful in constructing coordinate systems
\[ \vec{a} \times \vec{b}=\left(\begin{array}{c} y_{a} z_{b}-y_{b} z_{a} \\ z_{a} x_{b}-x_{a} z_{b} \\ x_{a} y_{b}-y_{a} x_{b} \end{array}\right) \]
Determine left / right
Determine inside / outside
Orthonormal Bases / Coordinate Frames
- Important for representing points, positions, locations
- Often, many sets of coordinate systems
- Global, local, world, model, parts of model (head,hands,...)
- Critical issue is transforming between these systems/bases
Any set of 3 vectors (in 3D) that
\[ \begin{gathered} \|\vec{u}\|=\|\vec{v}\|=\|\vec{w}\|=1 \\ \vec{u} \cdot \vec{v}=\vec{v} \cdot \vec{w}=\vec{u} \cdot \vec{w}=0 \\ \vec{w}=\vec{u} \times \vec{v} \quad \text { (right-handed) } \\ \vec{p}=(\vec{p} \cdot \vec{u}) \vec{u}+(\vec{p} \cdot \vec{v}) \vec{v}+(\vec{p} \cdot \vec{w}) \vec{w} \end{gathered} \]
Matrices
Array of numbers (m × n = m rows, n columns)
Addition and multiplication by a scalar are trivial: element by element
Matrix-Matrix Multiplication
(M x N) (N x P) = (M x P)
Element (i, j) in the product is the dot product of row i from A and column j from B
\[ \left(\begin{array}{ll}1 & 3 \\ 5 & 2 \\ 0 & 4\end{array}\right) \left(\begin{array}{llll}3 & 6 & 9 & 4 \\ 2 & 7 & 8 & 3\end{array}\right)= \left(\begin{array}{cccc}9 & ? & 33 & 13 \\ 19 & 44 & 61 & 26 \\ 8 & 28 & 32 & ?\end{array}\right) \]
Matrix-Vector Multiplication
- Treat vector as a column matrix (m×1)
- Key for transforming points
Vector multiplication
\[ \begin{aligned} \vec{a} \cdot \vec{b}&=\vec{a}^{T} \vec{b} \\ =&\begin{bmatrix}x_{a} & y_{a} & z_{a}\end{bmatrix} \begin{bmatrix}x_{b} \\ y_{b} \\ z_{b}\end{bmatrix} \\ =&\left(x_{a} x_{b}+y_{a} y_{b}+z_{a} z_{b}\right) \end{aligned} \]
\[ \vec{a} \times \vec{b}=A^{*} b= \left(\begin{array}{ccc} 0 & -z_{a} & y_{a} \\ z_{a} & 0 & -x_{a} \\ -y_{a} & x_{a} & 0 \end{array}\right) \left(\begin{array}{l} x_{b} \\ y_{b} \\ z_{b} \end{array}\right) \\ A:the\quad dual\quad matrix\quad of \quad vector\quad a \]