(GAMES101) 1 - Review && Transformation (2D/3D)
「転科・転専攻」は失敗したが、
千束ちゃんは「やりたいこと最優先!」と言ってくれました!
#1. Review of Linear Algebra
Vectors Normalization & Cartesian Coordinates
magnitude (length) : \(\Vert\vec a\Vert\)
unit vector : \(\hat a = \cfrac{\vec a}{\Vert {\vec a} \Vert}\)
\(\boldsymbol A = \begin{bmatrix} ~x~ \\ y \end{bmatrix} ~~~~~ \boldsymbol A^T = \begin{bmatrix} ~x , ~y~ \end{bmatrix} ~~~~~ \Vert \boldsymbol A \Vert = \sqrt{x^2 + y^2}\)
Dot (Scalar) Product
\(\vec a \cdot \vec b = \Vert \vec a \Vert \Vert \vec b \Vert \cos \theta ~~~~~ \cos \theta = \cfrac{\vec a \cdot \vec b}{\Vert \vec a \Vert \Vert \vec b \Vert}\)
for unit vectors : \(\cos \theta = \hat a \cdot \hat b\)
in cartesian coordinates : \(\vec a \cdot \vec b = \begin{bmatrix} ~x_a~ \\ y_a \\ z_a \end{bmatrix} \cdot \begin{bmatrix} ~x_b~ \\ y_b \\ z_b \end{bmatrix} = x_ax_b + y_ay_b + z_az_b\)
projection of \(\vec b\) onto \(\vec a\) : \(\Vert\vec b_{\perp}\Vert = \Vert \vec b \Vert \cos \theta\)
usage : intersection angle, decompose, determine for/backward
Cross (Vector) Product
construct coordinate systems
cartesian formula : \(\vec a \times \vec b = \begin{bmatrix} ~y_az_b - y_bz_a ~\\~ z_ax_b - x_az_b ~\\~ x_ay_b - y_ax_b ~\end{bmatrix}\)
usage : determine left / right, determine inside / outside
Matrix
array of numbers ($m \times n = $ m rows, n columns)
Matrix-Matrix Multiplication
require # columns in A = # rows in B
\((i, j)\) is dot product of \(\mathcal{row~ i~ from~ A}\) and \(\mathcal{column~ j~ from~ B}\)
-
non-commutative (\(AB\) and \(BA\) are different in general)
-
associative and distributive :
Matrix-Vector Multiplication
treat vector as a column matrix \(m \times 1\)
key for transforming points
Transpose of a Matrix
switch rows and columns
property : \((AB)^T = B^TA^T\)
Identity Matrix and Inverses
\(AA^{-1} = A^{-1}A = I ~~~~~~~~~ (AB)^{-1} = B^{-1}A^{-1}\)
#2. Transformation (2D)
Scaling
Reflection
horizontal reflection
Shearing
horizontal shift
Rotation
about the origin \((0,0)\), CCW by default
Linear Transforms = Matrices (of the same dimension)
Translation
In order to solve such the problem
2D point \(= (x, y, 1)^T\)
2D vector \(= (x, y, 0)^T\)
Matrix representation of translation
Valid operation if w-coordinate of result is \(1\) or \(0\)
- vector + vector = vector
- point - point = vector
- point + vector = point
- point + point = midpoint
In homogeneous coordinates, \(\begin{bmatrix} ~ x ~ \\ y \\ w \end{bmatrix}\) is the 2D point \(\begin{bmatrix} ~ x/w ~ \\ y/w \\ 1 \end{bmatrix},~w \neq 0\)
Affine map = linear map + translation (Linear Transforms First)
Using homogeneous coordinates
2D Transformations with homogeneous coordinates
Scale
Rotation
Translation
Inverse Transform
Composite Transform
Transform Ordering Matters !
Cause matrix multiplication is not commutative, matrices are applied right to left.
When we have a sequence of affine transforms \(A_1, A_2, A_3,~...\) :
Pre-multiply \(n\) matrices to obtain a single matrix for performance
Decomposing Complex Transform
eg. rotate around a given point c
#3. Transformation (3D)
Using homogeneous coordinates again !
- 3D point = \((x, y, z, 1)^T\)
- 3D vector = \((x, y, z, 0)^T\)
In general, \((x, y, z, w)~(w != 0)\) is the 3D point \((\cfrac{x}{w}, \cfrac{y}{w}, \cfrac{z}{w})\)
Use \(4 \times 4\) matrices for affine transformations
Scale
Translation
Rotation around x-, y-, or z-axis
Compose any 3D rotation from \(R_x, R_y, R_z\)
Euler angle (roll, pitch, yaw)
Rodrigues' Rotation Formula
Rotation by angle \(\alpha\) around axis \(\boldsymbol n\)

Review of Linear Algebra, Transformation (2D/3D)
// 虽然转专业失败了,但是千束ちゃん说了,「やりたいこと最優先!」
浙公网安备 33010602011771号