主要內容引自:
Addison.Wesley.OpenGL.SuperBible.5th.Edition.Jul.2010
CHAPTER 4
Basic Transformations:
A Vector/Matrix Primer
OpenGL的座標變換其實主要是理解各種矩陣變換,其實在各個領域都在用矩陣變換,OpenGL用到的只是3維(後擴展到4維)的矩陣變換。
1.向量
在OpenGL裏的向量定義有兩種方式:
typedef float M3DVector3f[3]; //只有XYZ座標
typedef float M3DVector4f[4];//XYZ座標加上縮放因子
向量運算主要有兩種形式:
Dot Product:點積,單位向量的點積可以表示兩個向量的夾角。
Cross Product:差積,可以計算出和兩個單位向量垂直的第三個向量,這樣只需給出某個座標系的兩個座標軸方向,自然可以計算出第三個座標軸方向。記得在電磁場理論裏也用叉積來計算由電流產生的磁場。
2.變換
有如下幾種變換:
Viewing: Specifies the location of the viewer or camera 觀察變換:定義觀察者位置或攝像頭位置
Modeling: Moves objects around the scene 物體變換:在場景中移動物體。
Modelview: Describes the duality of viewing and modeling transformations 描述觀察變換和物體變換的對偶性,因爲他們本來就是相對移動的。
Projection: Sizes and reshapes the viewing volume 投影變換:改變觀察空間的大小和形狀。
Viewport: A pseudo-transformation that scales the final output to the window 觀察窗口變換:從投影結果到窗口系統的變換。
待續......