最爱午后红茶

Matrices

日期图标
2023-03-15

Matrices

In Graphics, pervasively used to represent transformations

  • Translation, rotation, shear, scale

Matrices is array of numbers (m × n = m rows, n columns). Addition and multiplication by a scalar are trivial: element by element.

Matrix-Matrix Multiplication

  • (number of) columns in A must = rows in B
    • (M x N) (N x P) = (M x P)
    • (135204)(36942783)=(9273313194461268283212)\left(\begin{matrix}1 & 3\\5 & 2\\0 & 4\end{matrix}\right)\left(\begin{matrix}3 & 6 & 9 & 4\\2 & 7 & 8 & 3\end{matrix}\right) = \left(\begin{matrix}9 & 27 & 33 & 13\\19 & 44 & 61 & 26\\8 & 28 & 32 & 12\end{matrix}\right)
  • Element (i, j) in the product is the dot product of row i from A and column j from B
    • 比如上面矩阵相乘的结果,第二行第四列是 26,它等于矩阵 A 第二行 (52)\left(\begin{matrix}5 & 2\end{matrix}\right) 和矩阵 B 第四列 (43)\left(\begin{matrix}4\\3\end{matrix}\right) 的点积,即 26 = 5 × 4 + 2 × 3
  • Properties
    • Non-Commutative (AB and BA are different in general)
    • Associative and distributive
      • (AB)C=A(BC)
      • A(B+C) = AB + AC
      • (A+B)C = AC + BC

Matrix-Vector Multiplication

  • Treat vector as a column matrix (m×1)
  • Key for transforming points (next lecture)

Transpose of a Matrix

  • Switch rows and columns (ij -> ji)
    • (123456)T=(135246)\left(\begin{matrix}1 & 2\\3 & 4\\5 & 6\end{matrix}\right)^T = \left(\begin{matrix}1 & 3 & 5\\2 & 4 & 6\end{matrix}\right)
  • Property
    • (AB)T=BTAT(AB)^T = B^TA^T

Identity Matrix and Inverses

  • I3×3=(100010001)I_{3 \times 3} = \left(\begin{matrix}1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 1\end{matrix}\right)
  • AA1=A1A=IAA^{-1} = A^{-1}A = I
  • (AB)1=B1A1(AB)^{-1} = B^{-1}A^{-1}

单位矩阵可以定义矩阵的逆。如果两个矩阵(不论顺序)相乘的结果是单位矩阵,那么这两个矩阵是互逆的。

Vector multiplication in Matrix form

  • Dot product?
    • ab=aTb=(xayaza)(xbybzb)=(xaxb+yayb+zazb)\overrightarrow{a}\cdot\overrightarrow{b} = \overrightarrow{a}^T\overrightarrow{b} = \left(\begin{matrix}x_a & y_a & z_a\end{matrix}\right)\left(\begin{matrix}x_b\\y_b\\z_b\end{matrix}\right ) = (x_{a}x_{b} + y_{a}y_{b} + z_{a}z_{b})
  • Cross product?
    • a×b=Ab=(0zayaza0xayaxa0)(xbybzb)\overrightarrow{a}\times\overrightarrow{b} = A*\overrightarrow{b} = \left(\begin{matrix}0 & -z_a & y_a\\z_a & 0 & -x_a\\-y_a & x_a & 0\end{matrix}\right)\left(\begin{matrix}x_b\\y_b\\z_b\end{matrix}\right)

矩阵形式的向量叉乘跟旋转的推导有关,后续章节再具体说。

* 未经同意不得转载。