Computer Graphics: Geometric Transformations Geometric 2D transformations By: A. H. Abdul Hafez Abdul.hafez@hku.edu.tr, 1
Outlines 1. Basic 2D transformations 2. Matrix Representation of 2D transformations 3. Composite 2D transformations 2
Two-Dimensional Translation Movine a polygone from position (a) to position (b) with the translation vector (-5.50.3.75). 3
Two-Dimensional Rotation Parameters for the two-dimensional rotation are the rotation angle θ and a position (x r, y r ), called the rotation point (or pivot point), about which the object is to be rotated. The pivot point is the intersection position of the rotation axis with the xy plane. 4
Two-Dimensional Rotation To simplify the explanation of the basic method, we first determine the transformation equations for rotation of a point position P when the pivot point is at the coordinate origin. The original coordinates of the point in polar coordinates are 5
Two-Dimensional Rotation The transformation equations for rotation of a point about any specified rotation position (x r, y r ): 6
Two-Dimensional Scaling A line scaled using sx= sy = 0.5 is reduced in size and moved closer to the coordinate origin. 7
Two-Dimensional Scaling Relative scaling 8
Outlines 1. Basic 2D transformations 2. Matrix Representation of 2D transformations 3. Composite 2D transformations 9
General Matrix representation Each of the three basic two-dimensional transformations (translation, rotation, and scaling) can be expressed in the general matrix form with coordinate positions P and P' represented as column vectors. Matrix M 1 is a 2 by 2 array containing multiplicative factors, and M 2 is a two-element column matrix containing translational terms. 10
Homogeneous Coordinates Multiplicative and translational terms for a two-dimensional geometric transformation can be combined into a single matrix if we expand the representations to 3 by 3 matrices. Then we can use the third column of a transformation matrix for the translation terms, and all transformation equations can be expressed as matrix multiplications. A standard technique for accomplishing this is to expand each twodimensional coordinate-position representation (x, y) to a threeelement representation (x h, y h, h), called homogeneous coordinates, where the homogeneous parameter h is a nonzero value such that 11
Two-Dimensional Translation Matrix Two-Dimensional Translation Matrix T(tx, ty) as the 3 by 3 translation matrix. Two-Dimensional Rotation Matrix The rotation transformation operator R(0) is the 3 by 3 matrix Two-Dimensional Scaling Matrix The scaling operator S(sx, sy) is the 3 by 3 matrix 12
INVERSE TRANSFORMATIONS Inverse Translation Matrix Inverse Rotation Matrix Inverse Scaling Matrix 13
Outlines 1. Basic 2D transformations 2. Matrix Representation of 2D transformations 3. Composite 2D transformations 14
Introduction The coordinate position is transformed using the composite matrix M, rather than applying the individual transformations M 1 and then M 2. 15
Composite 2D translation 16
Composite 2D rotation 17
Composite 2D scaling 18
General 2D pivot-point rotation we can generate a two-dimensional rotation about any other pivot point (x r, y r ) by performing the following sequence of translaterotate-translate operations. 1. Translate the object so that the pivot-point position is moved to the coordinate origin. 2. Rotate the object about the coordinate origin. 3. Translate the object so that the pivot point is returned to its original position. 19
General 2D pivot-point rotation In general, a rotate function in a graphics library could be structured to accept parameters for pivot-point coordinates, as well as the rotation angle, and to generate automatically the rotation matrix. 20
General 2D fixed-point scaling 21
Other 2D Transformations Reflection: 22
Other 2D Transformations Shear: 23
Transformation between 2 coordinate systems To transform positioned object descriptions from xy coordinates to x'y' coordinates, we set up a transformation that superimposes the x'y' axes onto the xy axes. This is done in two steps: 1. Translate so that the origin (x 0, y 0 ) of the x'y' system is moved to the origin (0, 0) of the xy system 2. Rotate the x' axis onto the x axis. 24
The end of the Lecture Thanks for your time Questions are welcome 25