[計算機圖形學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

相關文章
相關標籤/搜索