《计算机图形学教学资料》.ppt
4.2 3D transformations,Translate(平移)transformationsScale(缩放)transformationsShear(错切)transformations Rotate(旋转)transformationsReflect(反射)transformationsComposition(复合)of 3D transformations,与二维平移变换类似地使用齐次坐标表示为:,记为:,其中,Translate transformation,记为:,Scale transformation,About origin,Cont.,About arbitrary point,The arbitrary reference point is:,Cont.,About arbitrary point,The arbitrary reference point is:,Cont.,则变换矩阵为:,Shear transformations,Dependence axis(依赖轴):corresponding coordinate is remained Direction axis(方向轴):corresponding coordinate is changed linearly Representations:,变换的一般表达式是:,Shear transformations,Parameters:rotate axis,rotate angle二维旋转变换是三维空间中绕Z轴的旋转,记为:,Rotate transformation,Rotate about X axis,Equally with changing the coordinate system x,y,z to the coordinate system y,z,x.,Rotate about Y axis,Changing system x,y,z to system z,x,y,?:about arbitrary line,是关于某直线或平面进行的关于某个轴进行的反射变换等同于关于该轴做180度的旋转变换For instance:about Z axis,Reflect transformation(反射变换),?:about arbitrary symmetry axis,Cont.,当反射平面是坐标平面时,等同于进行左、右手坐标系的互换,相应变换矩阵是把第三维坐标值取反For instance:about XOY plane,?About arbitrary symmetry plane,For instance:rotating about arbitrary line Overlapping arbitrary line with Z axisResolving a series of problems Reflect about an arbitrary symmetry lineReflect about an arbitrary symmetry plane,Composition transformations,旋转轴不与坐标轴重合时变换的实现:经复合变换使旋转轴与某坐标轴重合绕指定轴进行旋转变换还原坐标系,Rotate about arbitrary line,(1)translate P1 to overlap origin,不妨设P1P2为方向单位矢量,P2点坐标为(a,b,c),Cont.,P1,P2,Cont.,Cont.,(2)rotate about X axis to put the line on XOZ,X,Y,Z,Cont.,(2)rotate about X axis to put the line on XOZ,X,Y,Z,Cont.,(2)rotate about X axis to put the line on XOZ,X,Y,Z,Cont.,(2)rotate about X axis to put the line on XOZ,X,Y,Z,Cont.,(2)rotate about X axis to put the line on XOZ,X,Y,Z,Cont.,(2)rotate about X axis to put the line on XOZ,X,Y,Z,Cont.,(2)rotate about X axis to put the line on XOZ,X,Y,Z,Cont.,(2)rotate about X axis to put the line on XOZ,Then P2 is(a,0,d),Transformation matrix(变换矩阵),Cont.,(3)Rotate about Y axis to overlap the line with Z axis,X,Y,Z,Cont.,X,Y,Z,(4)Rotate about Z axis namely the line through,Cont.,X,Y,Z,P1,P2,Cont.,(4)recover the coordinate systemThe final transformation is:R()=T1-1Rx-1(-)Ry-1()Rz()Ry()Rx()T1,Cont.,关于任意直线(或平面)的反射可以分解为平移、旋转(使得指定的反射直线或平面与某坐标轴或平面重合)和关于坐标直线(或坐标平面)的反射,再加恢复变换。,Exercises out classroom,Exercise 4.11Given a unit cube with one corner at(0,0,0)and another opposite corner at(1,1,1),derive the transforations necessary to rotate the cube by degree about the main diagonal(对角线)(from(0,0,0)to(1,1,1)in the counterclockwise direction when looking along the diagonal toward the origin.,Exercises out classroom,Exercise 4.14An object is to be scaled by a factor S in the direction whose direction cosines are(,).Derive the transformation matrix.,Two methods of transformation,Coordinate system fixed,Graphics changedGraphics fixed,Coordinate system changed,(1)坐标系不变,图形变换;,(2)图形不变,坐标系变换.,变换的两种实现方法:,Transforming coordinate system,Two means:Define the new coordinate system directlyDefine a vector in y direction of the new coordinate system,Cont.,1.Define a new system:composition of transformations,(1)translate:T(-x0,-y0)(2)rotate:R(-)(3)scale(4)composition of above transformations(notice the sequence),Cont.,The matrix is:,Cont.,2.Define a vector in y direction of new system:,Y axis is:,X axis is:,Transformation is:,Contrast,VS.,Transform from an old coordinate system to another new coordinate systemThe new system is shown in the right figure:,Mode transformation,Cont.,Composition of translation and rotation:,当坐标系使用不同的缩放时,还需定义缩放补偿。,4.3 window-to-viewport transformation,World Domain(用户域WD)指程序员用来定义草图的整个自然空间.World-coordinate system(用户坐标系WC).世界坐标系右手直角坐标系Window(窗口区W)在用户坐标系(世界坐标系WC)中预先选定的将产生图形显示的区域称为窗口,Related concepts,Cont.,Screen Domain(屏幕域SD)设备输出图形的最大区域,是有限的整数域.Viewport(视图区V)在显示器坐标系中规定的显示图形的区域称为视(图)区.Screen coordinates(屏幕坐标系)(normalized)device coordinatesdevice coordinates:addressing by pixelsNDC:-1,1-a,a,Window as a viewfinder,Cont.,视见变换将用户坐标系中窗口内的图形变换到显示器中的视见区中产生显示.,Window-to-Viewport transformation,Cont.,Cont.,transform matrix,窗口,Wxl,Wxr,Wyb,Wyt,Cont.,NDC-to-DC transformation,NDC:-1,1-a,aDC:0,M-10,N-1Considering its discrete feature:-0.5,M-1.5-0.5,N-1.5The same linear transformation as the W-to-V transformationWhereas:,Flow chart of 2D view,二维图形显示流程,