Chapter4Transformations解说.ppt

(2)Rotate:绕原点逆时针方向旋转θ角 P’ →P” (3)Translate:旋转中心由坐标原点→原来位置 图形P” →P’” P’” = P·T(-Vx, -Vy)·TR(θ)·T(Vx, Vy) 其中, (Vx, Vy)为旋转中心的坐标 T(-Vx, -Vy)·TR(θ)·T(Vx,V y)= 图形关于任意直线的对称变换 P0(x0, y0) P1(x1, y1) P(x, y) P P’ P’ θ P” P” P(3) θ P(4) P(3) 1)平移变换T(x, y)使对称轴l过原点;2)旋转变换TR(θ)使之与x轴重合;3) 对称变换T1,求图形关于x轴的对称图形;4)旋转变换TR(-θ) ;5)平移变换T(-x, -y)使对称轴l回原位置。 P0 P1 P P(5) P(4) P(5) = P·T(-x, -y)·TR(-θ)·T1·TR(θ)·T(x, y) , 其中, cosθ= a / c sinθ= b / c a = x1 - x0, b = y1 - y0 c2 = a2 + b2 例:程序4.1 先平移后旋转 Translate2D(1,0);//向右平移一个单位 Rotate2D(45); //旋转45度 House( );//显示变换结果 4.3 2D graphics display process 二维图形的显示流程 坐标系建立了图形与数之间的关系。 世界坐标系(用户坐标系:用户用来定义图形对象的整个自然空间。) 局部坐标系(相对坐标系:用户用来定义局部图形相对位置的的坐标系。) 屏幕坐标系(设备坐标系:在输出设备上定义的坐标系。) 窗口(用户在世界坐标系中选择一个矩形域来指定要表示的图形。) 视区(用户在屏幕坐标系上选择一个矩形区来表示窗口内的图形。) 二维图形的显示流程 世界坐标系内的变换 关于窗口的裁剪 窗口到视区的变换 扫描转换 显示 世界 坐标系 设备坐标系 屏幕坐标系 视口2 viewport2 世界坐标系 world coordinates 屏幕坐标系 Screen coordinates 窗口 world window1 窗口到视区变换 window to viewport 视口1 viewport1 4.4 the window to viewport transformation窗口到视区的变换 WXL WXR WYB WYT VXL VXR VYB VYT (xw, yw) (xv, yv) 变换公式 Transformation formula the window to viewport transformation 窗口到视口的变换 xv = a·xw + b yv = c·yw + d 式中:a = (VXR – VXL)/(WXR-WXL) b=VXL – WXL*(VXR – VXL)/(WXR – WXL) c=(VYT – VYB)/(WYT – WYB) d=VYB – WYB*(VYT – VYB)/(WYT – WYB) The constants A and B scale the x and y coordinates, and C and D shift (or translate) them。常数A和B缩放x,y坐标,C和D平移x,y。 The mapping can be used with any point (x, y) inside or outside the window. Points inside the window map to points inside the viewport, and points outside the window map to points outside the viewport. 该映射可以用于所有点,窗口内映射视口内,窗口外映射是口外。 Ex. Consider the window and viewport of Fig.The window has (W.l, W.r, W.b, W.t) = (0, 2.0, 0, 1.0) and the viewport has (V.l, V.r, V.b, V.t) = (40, 400, 60, 300). Using the formulas,we obtain A = 180, C = 40, B = 240, D = 60 The center of the window (1.0, 0.5) maps to the center of the viewport (220, 180 ). Thus, the window to viewport mapping is: sx =

文档评论(0)

1亿VIP精品文档

相关文档