Geometric Transformations 1 Basic TwoDimensional Geometric Transformations Basic
Geometric Transformations 1
Basic Two-Dimensional Geometric Transformations • Basic geometric transformations: - Translation - Rotation - Scaling
Basic Two-Dimensional Geometric Transformation Two-Dimensional Translation • To translate a two-dimensional position, we add translation distances (translation vector) tx and ty to the original coordinates (x, y ) to obtain the new coordinate position (x', y') y 6 5 x' = x + tx y' = y + ty 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 Note: House shifts position relative to origin x
Basic Two-Dimensional Geometric Transformation Two-Dimensional Translation • With column-vector representation , , y 6 5 4 • Translation is a rigid-body transformation 3 2 1 0 1 2 3 4 5 6 7 8 9 10 x Note: House shifts position relative to origin
Basic Two-Dimensional Geometric Transformation Two-Dimensional Rotation • Need to specify: - Rotation angle - Rotation point (pivot point) - Rotation axis • Rotation is rigid-body transformation y 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 x
Basic Two-Dimensional Geometric Transformation Two-Dimensional Rotation • We first consider rotation about the origin in a two-dimensional planey • A positive value for the angle θ defines a counterclockwise rotation about the pivot point x
Basic Two-Dimensional Geometric Transformation Two-Dimensional Rotation • With column-vector representation
Basic Two-Dimensional Geometric Transformation Two-Dimensional Scaling • Scaling transformation alter the size of objects (non rigid-body transformation) • Performed by multiplying object positions (x, y) by scaling factors sx and sy to produce the transformed coordinates (x’, y’).
Basic Two-Dimensional Geometric Transformation Two-Dimensional Scaling • Any positive values can be assigned to the scaling factors. – Values less than 1 reduce the size of object; – Values greater than 1 produce enlargements. – Uniform scaling : scaling factors have the same value – Differential scaling : unequal values of the scaling factors
Matrix Representations and Homogeneous Coordinates • Many graphics applications involve sequences of geometric transformations. • Hence we consider how the matrix representations can be reformulated so that such transformation sequence can be efficiently processed. • Each of three basic two-dimensional transformations (translation, rotation and scaling) can be expressed in the general matrix form
Matrix Representations and Homogeneous Coordinates • To produce a sequence of transformations we could calculate the transformed coordinates one step at a time. Homogeneous Coordinates • The three geometric transformations can be combined into a single matrix if we expand the representations to 3 by 3 matrices • Then, we can use third column of a transformation matrix for the translation terms • All transformation equations can be expressed as matrix multiplications
Matrix Representations and Homogeneous Coordinates • A standard technique: expand each two-dimensional coordinate-position representation (x, y) to a threeelement representation (xh, yh, h), called homogeneous coordinates • The homogeneous parameter h is a nonzero value such that • A convenient choice is simply to set h=1. • Each two-dimensional position is then represented with homogeneous coordinate (x, y, 1).
Matrix Representations and Homogeneous Coordinates • Translation: gl. Translatef(x, y, z) • Rotation: gl. Rotatef(θ, x, y, z)
Matrix Representations and Homogeneous Coordinates • Scaling: gl. Scalef (x, y, z)
Inverse Transformations • Inverse translation matrix: • Inverse rotation matrix:
Inverse Transformations • Inverse scaling matrix:
Two-Dimensional Composite Transformations • Composite transformation matrix M = calculating the product of the individual transformations
Two-Dimensional Composite Transformations (1, 3) (2, 3) (3, 2) (-2, 1) (1, 1) (-1, 1) (2, 1) (a) (b) (-2, -1) (-1, -1) (0. 77, 1. 87) (-2. 23, -0. 13) (1. 63, 2. 37) (-1. 37, 0. 37) (c) (-0. 37, -1. 37) (-1. 23, -1. 87) (2. 63, 0. 63) (1. 77, 0. 13) (d)
Two-Dimensional Composite Transformations Composite Two-dimensional Translations
Two-Dimensional Composite Transformations Composite Two-dimensional Rotations
Two-Dimensional Composite Transformations Composite Two-dimensional Scales
Two-Dimensional Composite Transformations General Two-dimensional Pivot-Point Rotation • A transformation sequence for rotating an object about a specified pivot point using the rotation matrix R(θ). – Translate the object so that the pivot-point position is moved to the coordinate origin. – Rotate the object about the coordinate origin. – Translate the object so that the pivot point is returned to its original position.
Two-Dimensional Composite Transformations (xr, yr) (a) (xr, yr) (b) (xr, yr) (c) (xr, yr) (d)
Two-Dimensional Composite Transformations General Two-dimensional Pivot-Point Rotation
Exercise 1 Show the three transformation matrices used to rotate a figure 90 degrees counterclockwise about (5, 2). In what order must they be written to produce the correct concatenated transformation matrix: give the expression for the transformation of p(4, 3).
Exercise 1 Sol. • T(-5, -2): 1 0 -5 0 1 -2 001 • R(90): 0 -1 0 100 001 • T(5, 2): 105 012 001 • The complete transformation: T(5, 2) R(90) T(-5, -2)
Exercise 1 Sol. • M=T(5, 2) R(90) T(-5, -2) : 0 -1 7 1 0 -3 0 0 1 • The complete transformation: M P(4, 3) • The point will be |0 -1 7 | |1 0 -3 | |0 0 1 | |4 | | 3| |1 | = | 4| |1 |
Two-Dimensional Composite Transformations General Two-dimensional Fixed-Point Scaling • A transformation sequence to produce a twodimensional scaling with respect to a selected fixed position (xf, yf). – Translate the object so that the fixed point coincides with the coordinate origin. – Scale the object with respect to the coordinate origin. – Use the inverse of the translation in step (1) to return the object to its original position.
Two-Dimensional Composite Transformations (xf, yf) (a) (xf, yf) (b) (xf, yf) (c) (xf, yf) (d)
Two-Dimensional Composite Transformations General Two-dimensional Fixed-Point Scaling
Two-Dimensional Composite Transformations Matrix Concatenation Properties • The matrix product M 2 M 1 is not equal to M 1 M 2
Exercise 2 Show the two transformation matrices used to rotate a figure 90 degrees counter-clockwise about origin then translate the object by (4, 3). In what order must they be written to produce the correct concatenated transformation matrix: give the expression for the transformation of p(7, 1).
Exercise 2 Sol. • R(90): 0 -1 0 1 00 0 01 • T(4, 3): 104 013 001 • The complete transformation: T(4, 3) R(90) P(x, y) • It is not the same as the complete transformation: R(90) T(4, 3) P(x, y)
Exercise 2 Sol. • T(4, 3)R(90): 0 -1 4 1 0 3 0 0 1 • R(90)T(4, 3) : 0 -1 -3 10 4 00 1
Exercise 2 Sol. The complete transformation: T(4, 3) R(90) P(7, 1) |0 -1 4 | |7 | |3 | |1 0 3 | |1 | = | 10 | |0 0 1 | | 1 | • • It is not the same as the complete transformation: R(90) T(4, 3) P(7, 1) |0 -1 -3| |1 0 4| |0 0 1 | |7 | |1 | = |1 | | -4 | | 11| | 1|
Exercise 3 Show the three transformation matrices used to rotate a figure 60 degrees counter-clockwise about (3, 7). In what order must they be written to produce the correct concatenated transformation matrix: give the expression for the transformation of p(1, 3).
- Slides: 36