Introduction to Geometric Transformations 幾何轉換與座標轉換 KUAS ME, C. F. Chang 1 Contents of this section: Classification of Transformations Mathematic Representation of Geometric Transformations Definitions Related to Geometric Transformations Remarks on Homogeneous Coordinates The Graphics Pipeline OpenGL Functions for Setting up Transformations KUAS ME, C. F. Chang 國立高雄應用科技大學機械系 電腦繪圖學 C. F. Chang 2 1 Classification of Transformations Transformations are herein classified into two types: Geometric transformation (fix coordinates and manipulate objects, e.g., moving object) Coordinate transformation (fix objects and manipulate coordinates, e.g., moving camera The two transformations can have the same result Moving object Moving camera KUAS ME, C. F. Chang 3 Mathematic Representation of Geometric Transformations a. Translation, rotation, scaling, and shearing are all examples of geometric transformations. b. In the following, we will see that all the transformations of an object can be achieved by post multiplying a transformation matrix M by the object’ s vertices P. P’= M P m11 m12 m13 m14 x' x y ' m m m m y 21 22 23 24 m31 m32 m33 m34 z ' z m41 m42 m43 m44 w' w KUAS ME, C. F. Chang 國立高雄應用科技大學機械系 電腦繪圖學 C. F. Chang 4 2 Mathematic Representation of Geometric Transformations (cont) P’= M P ∵(P’ )T =( M P )T=PT MT ∴ Some graphics textbooks use a convention of premultiplying matrices by the row vectors of the object: x ' y ' z ' w ' x y z m11 m21 m31 m41 m m m m 12 22 32 42 w m13 m23 m33 m43 m14 m24 m34 m44 KUAS ME, C. F. Chang 5 Definitions Related to Geometric Transformations Affine transformation: A transformation, which preserves the parallelism of lines, but not necessarily angles or lengths. Coordinate systems: right-handed and left-handed coordinate systems KUAS ME, C. F. Chang 國立高雄應用科技大學機械系 電腦繪圖學 C. F. Chang 6 3 Definitions Related to Geometric Transformations (cont) Homogeneous coordinates : In homogeneous coordinates, each cartesian point (x,y,z) is represented in a redundant manner by 4 coordinates, (wx, wy, wz, w). Setting w=0 can be thought of as a point at infinity or, more simply, a direction. KUAS ME, C. F. Chang 7 Remarks on Homogeneous Coordinates Homogeneous coordinate systems use n+1 coordinates [X1, X2, …, Xn+1] to represent points [x1, x2, …, xn] in n-space and satisfy xi = Xi / Xn+1, i = 1, 2, …, n. [Ex1]: A point [x,y] is represented in homogeneous coordinates as [X, Y, W]. ∵ x = X / W, y = Y / W X=Wx,Y=Wy ∴ [X, Y, W] = [W x, W y, W] = W [x, y, 1] Thus, Thus a. Two sets of homogeneous coordinates with different values of W represent the same point, b. x = X and y = Y if W=1. KUAS ME, C. F. Chang 國立高雄應用科技大學機械系 電腦繪圖學 C. F. Chang 8 4 Remarks on Homogeneous Coordinates [Ex2]: For a straight line, we have x = X / W, y = Y / W a1 x + a2 y + a3=0 a1 (X/W) + a2 (Y/W) + a3=0 a1 X + a2 Y + a3 W = 0 (This is a homogeneous equation with each term having the same degree) a1 a2 X a3 Y 0 W KUAS ME, C. F. Chang 9 Remarks on Homogeneous Coordinates [Ex3]: For curves of two degrees, we have a x2 + b x y + c y2 + d x +e y + f = 0 x = X / W, y = Y / W a (X/W)2 + b (X/W) (Y/W) + c (Y/W)2 + d (X/W) +e (Y/W) + f = 0 a X2 + b X Y + c Y2 + d XW +e YW + f W 2 = 0 (Degree=2 for each term, homogeneous equation) X Y aX bY dW Z cY eW 0 fW X Y a b d X Z 0 c e Y 0 0 0 f W KUAS ME, C. F. Chang 國立高雄應用科技大學機械系 電腦繪圖學 C. F. Chang 10 5 The Graphics Pipeline Most rendering algorithms can be separated into two or more distinct stages. The graphics pipeline is a useful abstraction of the rendering process as well as a block diagram for dedicated graphics hardware (created by using Pov-Ray retracing) KUAS ME, C. F. Chang 11 Camera Analogy Setting up tripod and pointing the camera at the scene = viewing transformation Arranging the models to be photographed into the desired composition = modeling transformation Choosing a camera lens or adjusting the zoom = projection transformation Determining how large you want the final photograph to be - for example, enlarge or reduce the physical photograph = viewport transformation Each step uses transformations (i.e., a series of change in coordinate systems) and yields a transformation matrix KUAS ME, C. F. Chang 國立高雄應用科技大學機械系 電腦繪圖學 C. F. Chang 12 6 OpenGL Functions for Setting up Transformations object v e r t e x eye Modelview Matrix Projection Matrix Model view Projection Model: glTranslatef() glRotatef() glScalef() View: gluLookAt() Normalized device clip Perspective Division Perspective: glFrustum() gluPerspective() Orthogonal: glOrtho() gluOrtho2D() window Viewport Transform glViewport() KUAS ME, C. F. Chang 13 Stages of Vertex Transformation v ve vc vw ve M ModelViewv vc M Pr oject ve M Pr oject M ModelViewv vw MViewPort vc MViewPort M Pr oject M ModelViewv vw Mv , where M MViewPort M Pr oject M ModelView KUAS ME, C. F. Chang 國立高雄應用科技大學機械系 電腦繪圖學 C. F. Chang 14 7
© Copyright 2026 Paperzz