transformation
modeling translation rotation
viewing scaling (3D to 2D) projection
- scale
x ′ = s x y ′ = s y x'=sx\\ y'=sy x′=sxy′=sy
scale matrix
[ x ′ y ′ ] = [ s x 0 0 s y ] [ x y ] \left[ \begin{matrix} x'\\ y' \end{matrix} \right]= \left[ \begin{matrix} s_x & 0\\ 0 & s_y \end{matrix} \right] \left[ \begin{matrix} x\\ y \end{matrix} \right] [x′y′]=[sx00sy][xy]
Reflection matrix Shear matrix Rotation Matrix
[ − 1 0 0 1 ] [ − 1 a 0 1 ] [ c o s θ − s i n θ s i n θ c o s θ ] \left[ \begin{matrix} -1 & 0\\ 0 & 1 \end{matrix} \right] \left[ \begin{matrix} -1 & a\\ 0 & 1 \end{matrix} \right] \left[ \begin{matrix} cos\theta & -sin\theta\\ sin\theta & cos\theta \end{matrix} \right] [−1001][−10a1][cosθsinθ−sinθcosθ]
不想让平移作为特例,引入齐次坐标,希望包含所有变换
2D point = ( x , y , 1 ) T (x,y,1)^T (x,y,1)T 2D vector = ( x , y , 0 ) T (x,y,0)^T (x,y,0)T
[ x ′ y ′ w ′ ] = ( 1 0 t x 0 1 t y 0 0 1 ) ( x y 1 ) = ( x + t x y + t y 1 ) \left[ \begin{matrix} x'\\ y'\\ w' \end{matrix} \right]= \left( \begin{matrix} 1 & 0 & t_x\\ 0 & 1 & t_y\\ 0 & 0 & 1 \end{matrix} \right) \left( \begin{matrix} x\\ y\\ 1 \end{matrix} \right)= \left( \begin{matrix} x+t_x\\ y+t_y\\ 1 \end{matrix} \right) ⎣⎡x′y′w′⎦⎤=⎝⎛100010txty1⎠⎞⎝⎛xy1⎠⎞=⎝⎛x+txy+ty1⎠⎞
先旋转、后平移
矩阵的转置=矩阵的逆 ---------> 正交矩阵
R θ = [ c o s θ − s i n θ s i n θ c o s θ ] R − θ = [ c o s θ s i n θ − s i n θ c o s θ ] = R θ T R − θ = R θ − 1 R_\theta= \left[ \begin{matrix} cos\theta & -sin\theta\\ sin\theta & cos\theta \end{matrix} \right] \\ R_{-\theta}= \left[ \begin{matrix} cos\theta & sin\theta\\ -sin\theta & cos\theta \end{matrix} \right]=R_\theta^T\\ R_{-\theta}=R_\theta^{-1} Rθ=[cosθsinθ−sinθcosθ]R−θ=[cosθ−sinθsinθcosθ]=RθTR−θ=Rθ−1