[计算机图形学03]仿射变换和透视变换

前文中提到的模型变换(Model transform)和观察变换(View transform)是由缩放变换(Sacle transform),旋转变换(Rotation transform)和平移变换(Translation transform)这三种变换组合而成。其中缩放变换和旋转变换被称为线性变换(Linear transform),线性变换和平移变换统称为仿射变换(Affine transform)。spa

1.缩放变换,能够用一个3x3的矩阵描述orm

$$ M_{s} = \left[\begin{matrix} Scale_x & 0 & 0 \\ 0 & Scale_y & 0 \\ 0 & 0 & Scale_z \\ \end{matrix} \right] $$blog

Unity3D中使用列向量来描述顶点信息,因此能够把顶点坐标右乘缩放矩阵完成缩放操做。it

$$ \left[\begin{matrix} Scale_x & 0 & 0 \\ 0 & Scale_y & 0 \\ 0 & 0 & Scale_z \\ \end{matrix} \right] \left[\begin{matrix} x\\ y\\ z\\ \end{matrix} \right] = \left[\begin{matrix} Scale_x x \\ Scale_y y \\ Scale_z z\\ \end{matrix} \right] $$ io

2.旋转变换,能够用一个3x3的矩阵描述form

$$ M_{rx} = \left[\begin{matrix} 1 & 0 & 0 \\ 0 & cos\theta & -sin\theta \\ 0 & sin\theta & cos\theta \\ \end{matrix} \right] M_{ry} = \left[\begin{matrix} cos\theta & 0 & -sin\theta \\ 0 & 1 & 0 \\ 0 & sin\theta & cos\theta \\ \end{matrix} \right] M_{rz} = \left[\begin{matrix} cos\theta & -sin\theta & 0 \\ sin\theta & cos\theta & 0 \\ 0 & 0 & 1 \\ \end{matrix} \right] $$ class

3.平移变换,与缩放变换和旋转变换不一样平移变换是一个加法操做。事实上,用右乘一个3x3矩阵的方法是没法实现平移操做的,由于平移操做不是一个线性操做,因此咱们须要用到齐次坐标,把三维向量扩展成一个四维向量。扩展

$$ M_{t} = \left[\begin{matrix} 1 & 0 & 0 & t_x \\ 0 & 1 & 0 & t_y \\ 0 & 0 & 1 & t_z \\ 0 & 0 & 0 & 1 \\ \end{matrix} \right] $$transform

$$ \left[\begin{matrix} 1 & 0 & 0 & t_x \\ 0 & 1 & 0 & t_y \\ 0 & 0 & 1 & t_z \\ 0 & 0 & 0 & 1 \\ \end{matrix} \right] \left[\begin{matrix} x\\ y\\ z\\ w\\ \end{matrix} \right] = \left[\begin{matrix} x + t_x \\ y + t_y\\ z + t_z\\ w \end{matrix} \right] $$ 方法

4.仿射变换和投影变换的区别
120296-20160218190318191-1092432285.png

相关文章
相关标签/搜索