\documentclass{article} \usepackage[utf8]{inputenc} \usepackage[legalpaper, portrait, margin=1in]{geometry} \usepackage{hyperref} \usepackage{amsmath} \usepackage{tabulary} \title{Foundations of Game Engine Development 1: Mathematics} \author{bj} \date{August 2020} \begin{document} \maketitle \section{Vector Formulas} {\setlength{\extrarowheight}{10pt} \begin{tabulary}{8in}{LR} $ ||\textbf{v}|| = \sqrt{ v_x^2 + v_y^2 + v_z^2 + ...} $ & Vector Magnitude \\ $ ||\textbf{v}|| = \sqrt{ \textbf{v} \cdot \textbf{v} } $ & \\ $ ||t\textbf{v}|| = |t| ||\textbf{v}|| $ & Scalar magnitude property \\ $ \textbf{a} \cdot \textbf{b} = a_x b_x + a_y b_y + a_x b_z + ... $ & Dot product of vectors \\ $ \textbf{a} \cdot \textbf{b} = ||\textbf{a}|| ||\textbf{b}|| cos\theta $ & \\ $ \textbf{a} \cdot \textbf{a} = a^2$ & Notation (indicates a scalar result) \\ \textbf{a} and \textbf{b} are orthogonal (perpindicular) if $\textbf{a} \cdot \textbf{b} = 0$ & \\ $ \textbf{a} \times \textbf{b} = \begin{bmatrix} a_y b_z - a_z b_y \\ a_z b_x - a_x b_z \\ a_x b_y - a_y b_x \end{bmatrix} $ & Cross product on 3D vectors \\ $ \textbf{a} \times \textbf{b} = ||\textbf{a}|| ||\textbf{b}|| cos \theta$ & \\ $A = \frac{1}{2} ||(\textbf{p}_1 - \textbf{p}_0) \times (\textbf{p}_2 - \textbf{p}_0)|| $ & Area of a triangle defined by 3 points $\textbf{p}_0, \textbf{p}_1, \textbf{p}_2$ \\ $||\textbf{a} \times \textbf{b}|| = ||\textbf{a}|| ||\textbf{b}|| sin\theta$ & Magnitude of a cross product \\ $ \hat{\textbf{v}} = \frac{\textbf{v}}{||\textbf{v}||} $ & Normalize a vector (becomes a unit vector, members sum to 1) \\ $ \textbf{a} \times (\textbf{b} \times \textbf{c}) = \textbf{b}(\textbf{a} \cdot \textbf{c}) - \textbf{c}(\textbf{a} \cdot \textbf{b})$ & Vector Triple Product (``back minus cab'') \\ $ [ \textbf{a}, \textbf{b}, \textbf{c} ] = (\textbf{a} \times \textbf{b}) \cdot \textbf{c} = (\textbf{b} \times \textbf{c}) \cdot \textbf{a} = (\textbf{c} \times \textbf{a}) \cdot \textbf{b} $ & Scalar triple prodct. Equals the volume of a parallelepiped formed by a,b, and c. \\ $ [ \textbf{a}, \textbf{b}, \textbf{c} ] = -[ \textbf{c}, \textbf{b}, \textbf{a} ]$ & \\ $ \textbf{a}_{||\textbf{b}} = \frac{\textbf{a} \cdot \textbf{b}}{b^2} \textbf{b} $ & Projection of a onto b (cosine/X component) \\ $ \textbf{a}_{||\textbf{b}} = \frac{1}{b^2} \begin{bmatrix} b_x^2 & b_x b_y & b_x b_z \\ b_x b_y & b_y^2 & b_y b_z \\ b_x b_z & b_y b_z & b_z^2 \\ \end{bmatrix} \begin{bmatrix} a_x \\ a_y \\ a_z \\ \end{bmatrix} $ & Projection of a onto b with 3d vectors \\ $ \textbf{a}_{\perp \textbf{b}} = \textbf{a} - \textbf{a}_{||\textbf{b}} $ & Rejection of b from a (sin/Y component) \\ $ (\textbf{a}_{||\textbf{b}})^2 + (\textbf{a}_{\perp \textbf{b}})^2 = a^2 $ & Projection/Rejection property (pythagorean theorem) \\ $ \textbf{u}_1 = \textbf{v}_1, \textbf{u}_2 = \textbf{v}_2 - (\textbf{v}_2)_{||\textbf{u}_1}, \textbf{u}_3 = \textbf{v}_3 - (\textbf{v}_3)_{||\textbf{u}_1} - (\textbf{v}_3)_{||\textbf{u}_2}, ... $ & Gram-Schmidt process (orthogonal vectors set). \\ & Common to normalize each result (\textit{orthonormalization}) \\ $\textbf{a} \otimes \textbf{b} = \textbf{a} \textbf{b}^T = \begin{bmatrix}a_x \\ a_y \\ a_z \\ \end{bmatrix} \begin{bmatrix}b_x & b_y & b_z \\ \end{bmatrix} $ & 3D Vector Outer Product \\ $ = \begin{bmatrix} a_x b_z & a_x b_y & a_x b_z \\ a_y b_x & a_y b_y & a_y b_z \\ a_z b_x & a_z b_y & a_z b_z \\ \end{bmatrix} $ & \\ $ \textbf{v} = (v_x, v_y, v_z, 0)$ & Homogenous direction vector \\ $ \textbf{\textit{p}} = (v_x, v_y, v_z, 1)$ & Homogenous position vector \\ \end{tabulary} % Vector formulas table } \section{Matrix Formulas} {\setlength{\extrarowheight}{10pt} \begin{tabulary}{8in}{LR} $ \textbf{A}_{n,m}\textbf{B}_{m,p} = \textbf{C}_{n,p} $ & Matrix mult result size; also cols A must equal rows B \\ $ \textbf{M}_{i,j}^T = \textbf{M}_{j,i} $ & Matrix transpose \\ $ \textbf{M} = [\textbf{a} \textbf{b} \textbf{c}]$ & Column vector representation \\ $ \textbf{M} = \begin{bmatrix} X & a & b \\ a & X & c \\ b & c & X \end{bmatrix} $ & Symmetric matrix (X is be any value) \\ $\textbf{M}^T = \textbf{M}$ & \\ $ \textbf{M} = \begin{bmatrix} 0 & a & b \\ -a & 0 & c \\ -b & -c & 0 \end{bmatrix}$ & Antisymmetric matrix or skew-symmetric matrix (diagonals must be 0) \\ $\textbf{M}^T = -\textbf{M}$ & \\ $ \textbf{M}\textbf{v} = v_x \textbf{a} + v_y \textbf{b} + v_z \textbf{c}$ & Column vector mult notation (a,b,c cols of M) \\ $ \begin{vmatrix}a & b \\ c & d \end{vmatrix} = ad - bc$ & 2D Matrix determinant \\ $ det(\textbf{M}) = \sum\limits_{i=0}^{n-1} M_{ik}(-1)^{i+k}|\textbf{M}_{\bar{ik}}| $ & Recursive determinant (each $|M_{ik}|$ is the sub matrix excluding the current col) \\ & k is chosen as any row; good when row is mostly zeros\\ $ C_{ij}(\textbf{M}) = (-1)^{i+j}|\textbf{M}_{\bar{ij}}|$ & Cofactor matrix definition \\ $ \textbf{M}^{-1} = \frac{1}{det(\textbf{M})} \textbf{C}^T(\textbf{M})$ & Inverse; $C^T(M) =$ adjugate matrix \\ $\textbf{A}^{-1} = \frac{1}{A_{00}A_{11} - A_{01}A_{10}} \begin{bmatrix} A_{11} & -A_{01} \\ -A_{10} & A_{00} \end{bmatrix}$ & 2D Matrix inverse \\ $\textbf{B}^{-1} = \frac{1}{det(\textbf{B})} \begin{bmatrix} B_{11}B_{22} - B_{12}B_{21} & B_{02}B_{21} - B_{01}B_{22} & B_{01}B_{12} - B_{02}B_{11} \\ B_{12}B_{20} - B_{10}B_{22} & B_{00}B_{22} - B_{02}B_{20} & B_{02}B_{10} - B_{00}B_{12} \\ B_{10}B_{21} - B_{11}B_{20} & B_{01}B_{20} - B_{00}B_{21} & B_{00}B_{11} - B_{01}B_{10} \end{bmatrix} $ & 3D Matrix inverse \\ $ \textbf{M}^{-1} = \frac{1}{[\textbf{a},\textbf{b},\textbf{c}]} \begin{bmatrix} \textbf{b} \times \textbf{c} \\ \textbf{c} \times \textbf{a} \\ \textbf{a} \times \textbf{b} \\ \end{bmatrix} $ & 3D matrix inverse (a,b,c cols of M) \\ $\textbf{M}^{-1} = \frac{1}{\textbf{s} \cdot \textbf{v} + \textbf{t} \cdot \textbf{u}} \begin{bmatrix} \textbf{b} \times \textbf{v} + y\textbf{t} | -\textbf{b} \cdot \textbf{t} \\ \textbf{v} \times \textbf{a} - x\textbf{t} | \textbf{a} \cdot \textbf{t} \\ \textbf{d} \times \textbf{u} + w\textbf{s} | -\textbf{d} \cdot \textbf{s} \\ \textbf{u} \times \textbf{c} - z\textbf{s} | \textbf{c} \cdot \textbf{s} \end{bmatrix} $ & 4D Matrix inverse. a,b,c,d = 3D column vectors of M. \\ & x,y,z,w = last row of M, x = $a \times b$, t = $c \times d$, u = $ya -xb$, v = $wc -zd$ \\ \end{tabulary} % Matrix formulas table } \input{transformations.tex} \input{quaternions.tex} \input{geometry.tex} \input{grassman.tex} \end{document}