\documentclass{article} \usepackage{amsmath} \title{Notes} \author{Don Yang} \begin{document} \section{de Casteljau's algorithm} Interpolating between control points for a single component ($a$, $b$, $c$, and $d$ are control point values): \begin{align} ab &= a + t(b - a) \nonumber\\ bc &= b + t(c - b) \nonumber\\ cd &= c + t(d - c) \nonumber\\ abc &= ab + t(bc - ab) \nonumber\\ bcd &= bc + t(cd - bc) \nonumber\\ P(t) &= abc + t(bcd - abc) \end{align} \section{First derivative of cubic b\'ezier curves} Expand $P(t)$: \begin{align} ab &= (1 - t)a + t \cdot b \nonumber\\ bc &= (1 - t)b + t \cdot c \nonumber\\ cd &= (1 - t)c + t \cdot d \nonumber\\ abc &= (1 - t)ab + t \cdot bc \nonumber\\ &= (1 - t)((1 - t)a + t \cdot b) + t((1 - t)b + t \cdot c) \nonumber\\ &= (1 - t)^2 \cdot a + t(1 - t) \cdot b + t(1 - t) \cdot b + t^2 c \nonumber\\ &= (1 - t)^2 \cdot a + 2t(1 - t) \cdot b + t^2 c \nonumber\\ bcd &= (1 - t)^2 \cdot b + 2t(1 - t) \cdot c + t^2 d \nonumber\\ P(t) &= (1 - t)abc + t \cdot bcd \nonumber\\ &= (1 - t)((1 - t)^2 a + 2t(1 - t) b + t^2 c) + t((1 - t)^2 b + 2t(1 - t) c + t^2 d) \nonumber\\ &= (1 - t)^3 a + 2t(1 - t)^2 b + t^2(1 - t) c + t(1 - t)^2 b + 2t^2(1 - t) c + t^3 d \nonumber\\ &= (1 - t)^3 a + 3t(1 - t)^2 b + 3t^2(1 - t)c + t^3 d \end{align} Derivatives of each part: \begin{align} \frac{d}{dt} (1 - t)^3 &= 3(1 - t)^2 (-1) \nonumber\\ &= -3(1 - t)^2 \nonumber\\ \frac{d}{dt} 3t(1 - t)^2 &= 3(1 - t)^2 + 3t \cdot 2(1 - t)(-1) \nonumber\\ &= 3(1 - t)^2 - 6t(1 - t) \nonumber\\ \frac{d}{dt} 3t^2(1 - t) &= 6t(1 - t) + 3t^2(-1) \nonumber\\ &= 6t(1 - t) - 3t^2 \nonumber\\ \frac{d}{dt} t^3 &= 3t^2 \nonumber \end{align} First derivative: \begin{align} P'(t) &= -3(1 - t)^2 a + (3(1 - t)^2 - 6t(1 - t)) b + (6t(1 - t) - 3t^2) c + 3t^2 d \nonumber\\ &= 3(-(1 - t)^2 a + ((1 - t)^2 - 2t(1 - t)) b + (2t(1 - t) - t^2) c + t^2 d) \end{align} \section{Cross product of two vectors} \begin{align} \begin{vmatrix} i & j & k \\ a_x & a_y & a_z \\ b_x & b_y & b_z \end{vmatrix} &= i \begin{vmatrix} a_y & a_z \\ b_y & b_z \end{vmatrix} - j \begin{vmatrix} a_x & a_z \\ b_x & b_z \end{vmatrix} + k \begin{vmatrix} a_x & a_y \\ b_x & b_y \end{vmatrix} \nonumber\\ &= i(a_y b_z - b_y a_z) - j(a_x b_z - b_x a_z) + k(a_x b_y - b_x a_y) \end{align} \section{Rotation around unit vector} Let $\boldsymbol{u} = (x, y, z)^T$ be unit vector of rotation axis, and $\theta$ be the rotation angle, the rotation matrix is: \begin{align} \begin{bmatrix} 0 & -z & y \\ z & 0 & -x \\ -y & x & 0 \end{bmatrix} (sin \theta) + uu^T + (I - uu^T)(cos \theta) \end{align} Let $c\theta = cos \theta$ and $s\theta = sin \theta$: \begin{align} & \begin{bmatrix} 0 & -z & y \\ z & 0 & -x \\ -y & x & 0 \end{bmatrix} s\theta + uu^T + (I - uu^T)c\theta \nonumber\\ &= \begin{bmatrix} 0 & -z s\theta & y s\theta \\ z s\theta & 0 & -x s\theta \\ -y s\theta & x s\theta & 0 \end{bmatrix} + \begin{bmatrix} x^2 & xy & xz \\ xy & y^2 & yz \\ xz & yz & z^2 \end{bmatrix} + \begin{bmatrix} 1-x^2 & -xy & -xz \\ -xy & 1-y^2 & -yz \\ -xz & -yz & 1-z^2 \end{bmatrix} c\theta \nonumber\\ &= \begin{bmatrix} 0 & -z s\theta & y s\theta \\ z s\theta & 0 & -x s\theta \\ -y s\theta & x s\theta & 0 \end{bmatrix} + \begin{bmatrix} x^2 & xy & xz \\ xy & y^2 & yz \\ xz & yz & z^2 \end{bmatrix} + \begin{bmatrix} (1-x^2)c\theta & -xy c\theta & -xz c\theta \\ -xy c\theta & (1-y^2)c\theta & -yz c\theta \\ -xz c\theta & -yz c\theta & (1-z^2) c\theta \end{bmatrix} \nonumber\\ &= \begin{bmatrix} x^2 + (1 - x^2)c\theta & -z s\theta + xy - xy c\theta & y s\theta + xz - xz c\theta \\ z s\theta + xy - xy c\theta & y^2 + (1 - y^2)c\theta & -x s\theta + yz - yz c\theta \\ -y s\theta + xz - xz c\theta & x s\theta + yz - yz c\theta & z^2 + (1 - z^2) c\theta \end{bmatrix} \nonumber\\ &= \begin{bmatrix} x^2 + (1 - x^2)c\theta & -z s\theta + (1 - c\theta)xy & y s\theta + (1 - c\theta)xz \\ z s\theta + (1 - c\theta)xy & y^2 + (1 - y^2)c\theta & -x s\theta + (1 - c\theta)yz \\ -y s\theta + (1 - c\theta)xz & x s\theta + (1 - c\theta)yz & z^2 + (1 - z^2)c\theta \end{bmatrix} \nonumber\\ &= \begin{bmatrix} c\theta + (1 - c\theta)x^2 & -z s\theta + (1 - c\theta)xy & y s\theta + (1 - c\theta)xz \\ z s\theta + (1 - c\theta)xy & c\theta + (1 - c\theta)y^2 & -x s\theta + (1 - c\theta)yz \\ -y s\theta + (1 - c\theta)xz & x s\theta + (1 - c\theta)yz & c\theta + (1 - c\theta)z^2 \end{bmatrix} \end{align} \end{document}