人教小学信息第二册图形变换课件内容摘要:
系 oxyz中,求一个变换将P(1,1,1)Q(2,2,2)变换到 z轴上: P在坐标原点, Q在 z轴正半轴。 (方向数为:。 ) x y z P Q o x y z Q o(P) M 随堂练习 1. 写出三维基本几何变换的逆变换; 2. (教材 P213)将图 740中的物体 ABCDEFGH进行如下变换:平移使 C点与 P( 1, 1, 0)重合,然后绕 Z轴旋转 60度。 3. 将图 741中的空间四面体进行关于 P点的整体放大,试写出变换矩阵。 4. 假定空间直线 AB两端点坐标为 A(0,0,0)B(2,2,2),试写出绕 AB轴旋转 30度的三维复合变换矩阵。 5. **在右手坐标系中,从原点到 P( x,y,z)给出一直线,用三种方法将此直线旋转到正的轴线上,并用代数证明所得的结果等价。 a. 先绕 X轴旋转到 XZ平面上,再绕 Y轴到 Z轴上; b. 先绕 Y轴旋转到 YZ平面上,再绕 X轴到 Z轴上; c. 先绕 Z轴旋转到 XZ平面上,再绕 Y轴到 Z轴上 . 二维图形的显示流程图 绕绕任意点的旋转 x P(x, y) P’ (x’, y’) V = (Vx, Vy) y 1. 平移 P点经过矢量 V. 2. 绕原点旋转 . 3. 将 P点平沿矢量 V移回; Coordinate Transformations • We can think about, alternatively, a transformation is as a change of coordinate systems. (x,y) (x’,y’) (dx, dy) (x, y) (dx, dy) Coordinate Transformations • Objects are usually defined in theirs own local coordinate system. • We wish to express these objects’ coordinates in a single, global coordinate. – Object Coordinates – World Coordinates – Screen Coordinates Object Coordinates Objects are usually defined in their own local coordinate system. World Coordinates Represent these objects’ coordinates in a single, global coordinate. Screen Coordinates Finally, we want to project these objects onto the screen. Coordinate Hierarchy Object 1 Object Coordinates Transformation Object 1 World Object 2 Object Coordinates Transformation Object 2 World Object 3 Object Coordinates Transformation Object 3 World World Coordinates Transformation WorldScreen Screen Coordinates Transformations in OpenGL Transformations in OpenGL • Transformations are specified by matrix operations. Desired transformation can be obtained by a sequence of simple transformations that can be concatenated together. • Transformation matrix is usually represented by 4x4 matrix (homogeneous coordinates). • Provides matrix stacks for each type of supported matrix to store matrices. Transformation Matrices • Modelviewing matrix • Projection matrix • Texture matrix OpenGL Transformation Pipeline Programming Transformations • In OpenGL, the transformation matrices are part of the state, they must be defined prior to any vertices to which they are to apply. • In modeling, we often have objects specified in their own coordinate systems and must use transformations to bring the objects into the scene. • OpenGL provides matrix stacks for each type of supported matrix (modelview, projection, texture) to store matrices. Steps in Programming • Prior to rendering, view, locate, and orient: – Eye/camera position – 3D geometry • Manage the matrices – Including matrix stack • Composite transformations Current Transformation Matrix • Current Transformation Matrix (CTM) – The matrix that is applied to any vertex that is defined subsequent to its setting. • If change the CTM, we change the state of the system. • CTM is a 4 x 4 matrix that can be altered by a set of functions. Current Transformation Matrix The CTM can be set/reset/modify (by postmultiplication) by a matrix Ex: C = M // set to matrix M C = CT // postmultiply by T C = CS // postmultiply by S C = CR // postmultiply by R Current Transformation Matrix • Each transformation actually creates a new matrix that multiplies the CTM。 the result, which bees the new CTM. • CTM contains the cumulative product of multiplying transformation matrices. Ex: If C = M。 C = CT。 C = CR。 C = CS Then C = M T R S Ways to Specify Transformations • In OpenGL, we usually have two styles of specifying transformations: – Specify matrices ( glLoadMatrix, glMultMatrix ) – Specify operations ( glRotate, glTranslate ) Specifying Matrix • Specify current matrix mode • Modify current matrix • Load current matrix • Multiple current matrix Specifying Matrix (1) • Specify current matrix mode glMatrixMode (mode) Specified what transformation matrix is modified. mode: GL_MODELVIEW GL_PROJECTION GL_TEXTURE Specifying Matrix (2) • Modify current matrix glLoadMatrix{fd} ( Type *m ) Set the 16 values of current matrix to those specified by m. Note: m is the 1D array of 16 elements arranged by the columns of the desired matrix Specifying Matrix (3) • Modify current matrix glLoadIdentity ( void ) Set the currently modifiable matrix to the 4x4 identity matrix. Specifying Matrix (4) • Modify current matrix glMultMatrix{fd} ( Type *m ) Multiple the matrix specified by the 16 values pointed by m by the current matrix, and stores the result as current matrix. Note: m is the 1D array of 16 elements arranged by the columns of the desired matrix Specifying Operations • Three OpenGL operation routines for modeling transformations: – Translation – Scale – Rotation Problem • Modify cube program to translate, scale, and rotate using glMultMatrix (changes mented out) Specifying Operations (1) • Translation glTranslate {fd} (TYPE x, TYPE y, TYPE z)。人教小学信息第二册图形变换课件
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。