1、本文所以内容来自 著名高校课件和学生笔记(校园里面经常见到有人高价买笔记)
2、任课教师不会提供参考文献,所以只能对作者表示感谢,如果引用了您的作品,可以用回复方式补充参考文献。
3、我不对文章无关问题进行解答,文章内容也比较难,我也很难解答您遇到的问题,如果发现BUG可以用回复方式帮我修正。
4、本课 属于Computer Graphics
,适用于计算机图形学课程,教材为电子工业出版社Computer Graphics(计算机图形学,中文版和英文版)
本课其他部分的导航条见页面底部
Chapter 5 Geometric Transformations
§5.2 Matrix Representations(矩阵表示) and Homogeneous Coordinates(齐次坐标)
2D translation(平移)
2D rotation(旋转)
2D scaling(缩放)
Each basic transformation can be expressed in the matrix form:
Homogeneous Coordinates(齐次坐标)
If we expand the presentation to 3×3 matrices, geometry transformations can be combined in a single matrix.
We expand each 2D coordinate-position representation to a 3D representation
§5.4 2D Composite(复合) Transformations
Using matrix representations, we can set up a sequence of transformations as a composite transformation matrix (复合变换矩阵).
General 2D Pivot-Point(旋转点) Rotation
When a graphics package provides only a rotation function with respect to the coordinate origin, we can generate a 2D rotation about any pivot point by the following operators:
Translate the object so that the pivot point moves to the coordinate origin;
Rotate the object about the coordinate origin;
Translate the object so that the pivot point is returned to the original position.
General 2D Fixed-Point(基准点) Scaling
To generate a 2D scaling about any fixed point
by the following operators:
Translate the object so that the fixed point moves to the coordinate origin;
Scale the object about the coordinate origin;
Translate the object so that the pivot point is returned to the original position.
§5.6 Raster Operations for Geometry TransformMoving a block of pixels from a position to another position is called block transfer(块移动) .
ation
Raster Operations for Rotations with Any Angle
When the rotation angle is NOT the multiple of 90°, we map the destiny pixel to the rotated block.
In overlapped area, we use Interpolation(插值) and Anti-aliasing (反走样) technologies.
Raster Operations for Scale
In scale transformation, we map the destiny pixel to the rotated block.
In overlapped area, we use Interpolation(插值) and Anti-aliasing (反走样) technologies.
§5.9 3D Geometry Transformations
Methods for 3D geometry transformations are extended form 2D methods by including z coordinate.
General 3D Rotation
When the rotation axis is parallel to one of the coordinate axes,
We use Translation-Rotation-Translation composite transformation.
§5.16 Affine Transformations(仿射变换)
An affine transformation is a linear transformation.
Translation, rotation, scaling, reflection, and shear are examples of affine transformations.
Any affine transformation can be expressed as linear composites of the above transformations.
§5.17 OpenGL Geometry Transformation Functions
In the core library of OpenGL, a separate function is available for each of basic transformations.
All transformation are specified in 3D dimensions.
To construct a translation matrix:
glTranslate* (tx, ty, tz); // * can be f(float) or d(double)
Eg. glTranslatef (10.0, 20.0, 30.0);
glTranslated (10.0, 20.0, 30.0);
To construct a rotation matrix:
glRotate* (theta, vx, vy, vz); // theta means the rotate angle, (vx,vy,vz) determines the rotate axis.
Eg. glRotatef (90.0, 0.0, 0.0, 1.0);
glRatatef (180.0, 0.0, 1.0, 0.0);
To construct a Scaling matrix:
glScale* (sx, sy, sz); // scaling factors can NOT be zero
Eg. glRotatef (2.0, 1.0, 1.0);
When a scaling factor is negative(负的), the scaling matrix can also generate reflections.
Eg. glScalef (2.0, 1.0, -1.0);
// scale by a factor of 2 in the X direction,
// and reflect about the XY Plane.
OpenGL Matrix Operations —— to Set the Matrix Mode
To set the model view (建模观察) matrix mode:
glMatrixMode ( GL_MODEVIEW );
This routine designates a 4×4 modeview matrix as the current matrix .
When in MODEVIEW mode, a call to a transformation routines generate a matrix that is multiplied by the current matrix .
OpenGL Matrix Operations —— to Assign the Current Matrix
Assign the identity matrix (单位矩阵) to the current matrix:
glLoadIdentity ( );
Assign other values to the current matrix:
float array[16]= { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 } ;
glLoadMatrixf ( array );
Note: the elements of array are arranged in column-major order
Concatenate a specified Matrix with the Current Matrix
Assign a matrix : (the elements of array are arranged in column-major order)
float array[16]= { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 } ;
The current matrix is post-multiplied(右乘) by array:
glMultMatrixf ( array );
OpenGL Matrix Stacks
For each of the four matrix modes, OpenGL maintains a matrix stack.
At any time, the top matrix on each stack is called the “current matrix”.
glPushMatrix ( ); // copy the current matrix and
// store that copy in the second stack position
glPopMatrix ( ); // destroy the matrix at the top,
// and the second become the current matrix