GAMES101 Notes_Lec02_Review of Linear Algebraphics

A Swift and Brutal Introduction to Linnear Alfebra!

0 Graphics' Dependencies... Graphics' Dependencies

  • Basic Mathematics
    • linear algebra linear algebra
    • calculus
    • Statistics statistics
  • basic physics
    • Optical Optics
    • Mechanics
  • other
    • signal processing signal processing
    • numerical analysis numerical analysis
    • A bit of aesthetics

1 Vector Vectors

1.1 Vector Normalization of Vector Normalization

a ^ = a ⃗ / ∣ a ∣ \hat{a} = \vec{a}/|a| a^=a /a

1.2 Vector Addition Vector Addition

  • Geometry Understanding Grometrically
    • Parallelogram law & Triangle law
  • algebraically
    • 各坐标相加 Simply add coordinates
      A = 4 x + 3 y ,    A = ( x y ) ,    A T = ( x , y ) ,    ∣ A ∣ = x 2 + y 2 \boldsymbol{A}=4x+3y,\; \boldsymbol{A}=\begin{pmatrix}x\\y\end{pmatrix},\; \boldsymbol{A}^T=(x,y),\; |\boldsymbol{A}|=\sqrt{x^2+y^2} \quad A=4x _+3 years _A=(xy),AT=(x,y),A=x2+y2

1.3 Vector dot product Dot(scalar) Product

1.3.1 Definition and usage

a ⃗ ⋅ b ⃗ = ∣ a ⃗ ∣ ∣ b ⃗ ∣ cos ⁡ θ , cos ⁡ θ = a ⃗ ⋅ b ⃗ ∣ a ⃗ ∣ ∣ b ⃗ ∣ cos ⁡ θ \vec{a}\cdot\vec{b} =|\vec{a}||\vec{b}|\cos\theta,\; \cos\theta=\frac{\vec{a}\cdot\vec{b}}{|\vec{a}||\vec{b}|\cos\theta}a b =a b cosi ,cosi=a b cosia b
For unit vectors: cos θ = a ^ ⋅ b ^ For unit vectors: \quad cos\theta=\hat{a}\cdot\hat{b}For a unit vector:cosθ=a^b^

1.3.2 Properties

a ⃗ ⋅ b ⃗ = b ⃗ ⋅ a ⃗ \vec{a}\cdot\vec{b}=\vec{b}\cdot\vec{a}a b =b a
a ⃗ ⋅ ( b ⃗ + c ⃗ ) = a ⃗ ⋅ b ⃗ + a ⃗ ⋅ c ⃗ \vec{a}\cdot(\vec{b}+\vec{c})=\vec{a}\cdot \vec{b}+\vec{a}\cdot\vec{c}a (b +c )=a b +a c
( ka ⃗ ) ⋅ b ⃗ = a ⃗ ⋅ ( kb ⃗ ) = k ( a ⃗ ⋅ b ⃗ ) (k\vec{a})\cdot\vec{b}=\vec{a}\cdot(k\ vec{b})=k(\vec{a}\cdot\vec{b})(ka )b =a (kb )=k(a b )

1.3.3 Dot Product in Cartesian Coordinates

  • In 2D
    a ⃗ ⋅ b ⃗ = ( x a y a ) ⋅ ( x b y b ) = x a x b + y a y b \vec{a}\cdot\vec{b}=\begin{pmatrix} x_a \\ y_a \\ \end{pmatrix}\cdot\begin{pmatrix} x_b \\ y_b \\ \end{pmatrix}=x_ax_b+y_ay_b a b =(xaya)(xbyb)=xaxb+yayb
  • In 3D
    a ⃗ ⋅ b ⃗ ⋅ c ⃗ = ( x a y a z a ) ⋅ ( x b y b z b ) = x a x b + y a y b + z a z b \vec{a}\cdot\vec{b}\cdot\vec{c}=\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 a b c =xayazaxbybzb=xaxb+yayb+zazb

1.3.4 Dot Product for Graphics

  • Find angle between two vectors (eg cosine of angle between light source and surface)

  • Finding projection of one vector on another
    insert image description here

    b ⃗ ⊥ = to ^ , k = ∣ b ⃗ ⊥ ∣ = ∣ b ⃗ ∣ cos ⁡ θ \vec{b}_\bot=k\hat{a},\;k=|\vec{b}_\ bot|=|\vec{b}|\cos\thetab =ka^,k=b =b cosi

  • Measure how close two directions are

  • Decompose a vector Decompose a vector
    insert image description here

  • Judgment towards Determine forward / backward
    insert image description here

1.4 Cross product of vector Cross(vector) Product

1.4.1 Definition and usage

  • The result of the cross product is a vector, perpendicular to the two initial vectors Cross product is orthogonal to two initial vectors
  • The result of the cross product is determined by the right-hand rule Direction determined by right-hand rule
  • Useful in constructing coordinate systems
  • The modulus of the cross product result is equal in size to the area of ​​the triangle formed by the two vectors
    ∣ a ⃗ × b ⃗ ∣ = ∣ a ⃗ ∣ ∣ b ⃗ ∣ sin ⁡ θ |\vec{a}\times\vec{b}| =|\vec{a}||\vec{b}|\sin\thetaa ×b =a b sini

1.4.2 Properties

a ⃗ × a ⃗ = 0 ⃗ \vec{a}\times\vec{a}=\vec{0}a ×a =0
a ⃗ × b ⃗ = − b ⃗ × a ⃗ \vec{a}\times\vec{b}=-\vec{b}\times\vec{a}a ×b =b ×a
a ⃗ × ( b ⃗ + c ⃗ ) = a ⃗ × b ⃗ + a ⃗ × c ⃗ \vec{a}\times(\vec{b}+\vec{c})=\vec{a}\times \vec{b}+\vec{a}\times\vec{c}a ×(b +c )=a ×b +a ×c
a ⃗ × ( kb ⃗ ) = k ( a ⃗ × b ⃗ ) \vec{a}\times(k\vec{b})=k(\vec{a}\times\vec{b})a ×(kb )=k(a ×b )

1.4.3 Cross Product: Cartesian Formula in the Cartesian coordinate system

a ⃗ × b ⃗ = ( y a z b − y b z a z a x b − x a z b x a y b − y a x b ) \vec{a}\times\vec{b}=\begin{pmatrix} y_az_b-y_bz_a \\ z_ax_b-x_az_b \\x_ay_b-y_ax_b \end{pmatrix} a ×b =yazbybzazaxbxazbxaybyaxb

1.4.4 Cross Product in Graphics

  • determine left and right

    • As shown in the figure below, in the right-handed coordinate system, the result of cross multiplying vector b by a vector is positive, then b is on the left side of a
      insert image description here
  • judging inside and outside

    • As shown in the figure below, if the result of cross multiplying three times in order is positive or negative, it is internal, otherwise it is external
      insert image description here

1.5 Orthonormal Bases / Coordinate Frames

If there are three vectors satisfying ∣ u ⃗ ∣ = ∣ v ⃗ ∣ = ∣ w ⃗ ∣ = 1 , u ⃗ ⋅ v ⃗ + v ⃗ ⋅ w ⃗ + u ⃗ ⋅ w ⃗ = 0 , w ⃗ = u ⃗ × v ⃗ If there are three vectors satisfying \quad|\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}If there are three vectors satisfyingu =v =w =1,u v +v w +u w =0,w =u ×v
刪 p ⃗ = ( p ⃗ ⋅ u ⃗ ) u ⃗ + ( p ⃗ ⋅ v ⃗ ) v ⃗ + ( p ⃗ ⋅ w ⃗ ) w ⃗ 刪\quad \vec{p}=(\vec{p}\cdot \vec{u})\vec{u}+(\vec{p}\cdot\vec{v})\vec{v}+(\vec{p}\cdot\vec{w})\vec{w }butp =(p u )u +(p v )v +(p w )w

2 Matrix Matrix

In Graphics,
pervasively used to represent transformations

2.1 What is a matrix What is a matrix

  • Array of numbers (m × n = m rows, n columns)
  • Addition and multiplication by a scalar are trivial: element
    by element

2.2 Matrix-Matrix Multiplication

  • The number of columns in A must equal to the number of rows in B
    ( M × N ) ( N × P ) = ( M × P ) (M\times N )(N\times P)=(M\times P)(M×N)(N×P)=(M×P)
  • The element (i,j) in the product is the dot product result of row i in A and column j in B
    ( 1 3 5 2 0 4 ) ( 3 6 9 4 2 7 8 3 ) = ( 9 27 33 13 19 44 61 26 8 28 32?) \ Begin {pmatrix} 1 & 3 \\ 5 & 2 \ \ \ 0 & 4 \ end {pmatrix} \ begin {pmatrix} 3 & 6 & 9 & 4 \ 8 & 8 & end {pmatrix} = \ be = \ be gin {pmatrix} 9 & 27 & 33 & 13 \\ 19 & 44 & 61 & 26 \\8&28&32&? \end{pmatrix}150324(32679843)=91982744283361321326?
    ? = ( 0 , 4 ) ⋅ ( 4 , 3 ) = 0 + 12 = 12 ?=(0,4)\cdot(4,3)=0+12=12 ?=(0,4)(4,3)=0+12=12

2.3 Properties of the matrix

  • Non-commutative(AB and BA are different in general)
  • Associative and distributive
    ( AB ) C = A ( BC ) , A ( B + C ) = AB + AC (AB)C=A(BC),\;A(B+C)=AB+ AC(AB)C=A ( B C ) ,A(B+C)=AB+AC

2.4 Matrix-Vector Multiplication

  • Treat vector as a column matrix (m×1)
  • Is the core of the transformation Key for transforming points
    Symmetrical transformation about the y-axis: ( − 1 0 0 1 ) ( xy ) = ( − xy ) Symmetrical transformation about the y-axis:\quad\begin{pmatrix} -1&0\\0&1\ \ \end{pmatrix}\begin{pmatrix} x \\ y \\ \end{pmatrix}=\begin{pmatrix} -x \\ y \\ \end{pmatrix}A transformation that is symmetric about the y- axis:(1001)(xy)=(xy)

2.5 Transpose of a Matrix

  • Interchange the rows and columns of the matrix Switch rows and columns (ij -> ji)
    ( 1 2 3 4 5 6 ) T = ( 1 3 5 2 4 6 ) \begin{pmatrix} 1&2\\3&4\\5&6 \end {pmatrix}^T=\begin{pmatrix} 1&3&5\\2&4&6\\ \end{pmatrix}135246T=(123456)
  • The nature of transposition Property
    ( AB ) T = BTAT (AB)^T=B^TA^T(AB)T=BT AT

2.6 Identity Matrix and Inverses

  • Identity Matrix
    • The diagonals of the identity matrix are all 1
      I 3 × 3 = ( 1 0 0 0 1 0 0 0 1 ) I_{3×3}=\begin{pmatrix} 1&0&0\\0&1&0\\0&0&1 \end{pmatrix}I3×3=100010001
  • Inverse matrix Inverses
    • The product of two matrices is an identity matrix, then the two matrices are inverse
      AA − 1 = A − 1 A = I AA^{-1}=A^{-1}A=IAA1=A1A=I
    • Properties of Inverse Matrix
      ( AB ) − 1 = B − 1 A − 1 (AB)^{-1}=B^{-1}A^{-1}(AB)1=B1A1

3 Vector multiplication in Matrix form

3.1 Dot product

a ⃗ ⋅ b ⃗ = a ⃗ T b ⃗ = ( x a y a z a ) ( x b y b z b ) = ( x a x b y a y b z a z b ) \vec{a}\cdot\vec{b}=\vec{a}^T\vec{b}=\begin{pmatrix} x_a&y_a&z_a\end{pmatrix}\begin{pmatrix} x_b\\y_b\\z_b \end{pmatrix}=\begin{pmatrix} x_ax_b&y_ay_b&z_az_b\end{pmatrix} a b =a Tb =(xayaza)xbybzb=(xaxbyaybzazb)

3.2 Cross product

a ⃗ × b ⃗ = A ∗ b ⃗ = ( 0 − zayaza 0 − xa − yaxa 0 ) ⏟ a vector adjoint matrix ( dual matrix ) ( xbybzb ) \vec{a}\times\vec{b}=A^ *\vec{b}=\underbrace{\begin{pmatrix} 0&-z_a&y_a\\z_a&0&-x_a\\-y_a&x_a&0 \end{pmatrix}}_{\rm{a vector adjoint matrix (dual\,matrix)} }\begin{pmatrix} x_b\\y_b\\z_b \end{pmatrix}a ×b =Ab =a vector adjoint matrix ( d u a l _matrix) 0zayaza0xayaxa0xbybzb

Guess you like

Origin blog.csdn.net/Ziiur/article/details/122782125