360 likes | 388 Views
Two-Dimensional Geometric Transformations. Chapter 5. Two-Dimensional Geometric Transformations. Basic Transformations Translation Rotation Scaling Composite Transformations Other transformations Reflection Shear. Translation. Translation transformation
E N D
Two-Dimensional Geometric Transformations • Basic Transformations • Translation • Rotation • Scaling • Composite Transformations • Other transformations • Reflection • Shear
Translation • Translation transformation • Translation vector or shift vector T = (tx, ty) • Rigid-body transformation • Moves objects without deformation y y P’ T T p x x
Rotation • Rotation transformation x’=rcos(+)= rcoscos-rsin sin y’=rsin(+)= rcossin+rsin cos y x=rcos y=rsin P’ (x’,y’) x’=x cos-ysin y’=xsin+ycos P(x,y) r x P’= R· P
Rotation • Pivot point x’=xr+(x- xr)cos-(y- yr)sin y’=yr+(x- xr)sin+(y- yr)cos y P’ (x’,y’) P(x,y) r (xr,yr) x
Scaling • Scaling transformation • Scaling factors, sx and sy • Uniform scaling y y x x
Scaling • Fixed point
Matrix Representations and Homogeneous Coordinates • Homogeneous Coordinates • Matrix representations • Translation
Matrix Representations • Matrix representations • Scaling • Rotation
Composite Transformations • Translations
Composite Transformations • Scaling
Composite Transformations • Rotations
General Pivot-Point Rotation • Rotations about any selected pivot point (xr,yr) • Translate-rotate-translate
General Fixed-Point Scaling Scaling with respect to a selected fixed position (xf,yf)
General Fixed-Point Scaling • Translate-scale-translate
General Scaling Directions • Scaling factors sx and sy scale objects along the x and y directions. • We scale an object in other directions with scaling factors s1 and s2
Concatenation Properties • Matrix multiplication is associative. A·B ·C = (A·B )·C = A·(B ·C) • Transformation products may not be commutative • Be careful about the order in which the composite matrix is evaluated. • Except for some special cases: • Two successive rotations • Two successive translations • Two successive scalings • rotation and uniform scaling
Concatenation Properties • Reversing the order • A sequence of transformations is performed may affect the transformed position of an object.
General Composite Transformations and Computer Efficiency • A general two-dimensional transformation • Rotation-scaling terms rsij • Translational terms trsx and trsy • Minimum number of computations • Four multiplications • Four additions
Rigid-Body Transformation • Rigid-body transformation matrix • The upper-left 2-by-2 submatrix is an orthogonal matrix • Two vectors (rxx, rxy) and (ryx, ryy) form an orthogonal set of unit vectors. • Multiplicative rotation terms rij • Translational terms trx and try
Rigid-Body Transformation • The orthogonal property of rotation matrices • We know the final orientation of an object Construct the desired transformation by assigning the elements of u’ to the first row of the rotation matrix and the elements of v’ to the second row.
Computational Efficiency • Use approximations and iterative calculations to reduce computations • Approximate the trigonometric functions based on the first few terms of their power-series expansions. • For small enough angles (< 100), cos is approximately 1.sin is approximately • Accumulated error control • Estimate the error in x’ and y’ at each step • Reset object positions when the error accumulation becomes too great
Reflection • A transformation produces a mirror image of an object. • Axis of reflection • A line in the xy plane • A line perpendicular to the xy plane • The mirror image is obtained by rotating the object 1800 about the reflection axis. • Rotation path • Axis in xy plane: in a plane perpendicular to the xy plane. • Axis perpendicular to xy plane: in the xy plane.
Reflection • Reflection about the x axis
Reflection • Reflection about the y axis
Reflection • Reflection relative to the coordinate origin
Reflection • Reflection of an object relative to an axis perpendicular to the xy plane through Prfl
Reflection • Reflection about the line y = x
Shear • The x-direction shear relative to x axis If shx = 2:
Shear • The x-direction shear relative to y = yref If shx = ½ yref = -1: 1 1/2 3/2
Shear • The y-direction shear relative to x = xref 3/2 If shy = ½ xref = -1: 1/2 1
Transformations between Coordinate Systems y y y’ x’ y’ θ y0 x’ θ x x x0
Transformations between Coordinate Systems Method 1: Method 2:
Affine Transformations • A coordinate transformation of the form x’=axxx+axyy+bx, y’=ayxx+ayyy+by • x’ and y’ is a linear function of the original coordinates x and y. • aij and bk are constants determined by the transformation type. • Translation, rotation, scaling, reflection, and shear are two-dimensional affine transformations. • An affine transformation involving only rotation, translation, and reflection preserves angles and lengths.