2D Geometrical Transformations • Translation - Moves points to new locations by adding translation amounts to the coordinates of the points . P’ (x’,y’) T . P(x,y) x′ x dx x′ = x + dx, y′ = y + dy or = + y′ y dy P′ = P + T - To translate an object, translate every point of the object by the same amount (translate only the endpoints of line segments - redrawing is required) -2• Scaling - Changes the size of the object by multiplying the coordinates of the points by scaling factors x′ s x x′ = x s x , y′ = y s y or = y′ 0 0 x , s x ,s y > 0 sy y P′ = S P - Scale factors affect size as following: * If s x = s y uniform scaling * If s x ≠ s y nonuniform scaling * If s x , s y < 1, size is reduced, object moves closer to origin * If s x , s y > 1, size is increased, object moves further from origin * If s x = s y = 1, size does not change -3- Control the location of a scaled object by choosing the location of a point (fixed point) with respect to which the scaling is performed P2 P1 . P3 (Xf,Yf) x′ = x f + (x − x f )s x or x′ = xs x + x f (1 − s x ) y′ = y f + (y − y f )s y or y′ = ys y + y f (1 − s y ) x′ s x = y′ 0 0 x x f (1 − s x ) + s y y y f (1 − s y ) P′ = S P + T f -4• Rotation - Rotates points by an angle about origin ( >0: counterclockwise rotation) - From ABP triangle: cos( ) = x/r or x = rcos( ) sin( ) = y/r or y = rsin( ) - From ACP′ triangle: cos( + ) = x′/r or x′ = rcos( + ) = rcos( )cos( ) − rsin( )sin( ) sin( + ) = y′/r or y′ = rsin( + ) = rcos( )sin( ) + rsin( )cos( ) - From the above equations we have: x′ = xcos( ) − ysin( ), y′ = xsin( ) + ycos( ) or x′ cos( ) −sin( ) x = y′ sin( ) cos( ) y P′ = R P - To rotate an object, rotate every point of the object by the same amount -5(rotate only the endpoints of line segments - redrawing is required) - Performing rotation about an arbitrary point . P’(x’,y’) . r . P(x,y) r Pr (Xr,Yr) x′ = x r + (x − x r )cos( ) − (y − y r )sin( ) y′ = y r + (x − x r )sin( ) + (y − y r )cos( ) x′ cos( ) −sin( ) x − x r x r + = y − y y′ sin( ) cos( ) r yr P′ = R(P − P r ) + P r • Summary of transformations Translation: P′ = P + T (addition causes problems !!) Scale: P′ = S P Rotation: P′ = R P - Idea: use homogeneous coordinates to express translation as matrix multiplication -6• Homogeneous coordinates (projective space) - Idea: add a third coordinate: (x, y) --> (x h , y h , w) - Homogenize (x h , y h , w): x= yh xh , y= ,w≠0 w w - In general: (x, y) --> (xw, yw, w) (i.e., x h =xw, y h =yw) - w can assume any value (w ≠ 0), for example, w = 1: (x, y) − − > (x, y, 1) (no division is required when you homogenize !!) (x, y) − − > (2x, 2y, 2) (division is required when you homogenize !!) - (x, y) can be represented by an infinite number of points in homogeneous coordinates If w = 6, (1/3, 1/2) − − > (2, 3, 6) If w = 12, (1/3, 1/2) − − > (4, 6, 12) ... - All these points lie on a line in the space of homogeneous coordinates !! -7• Translation using homogeneous coordinates x′ 1 y′ = 0 1 0 0 1 0 dx x dy y 1 1 (Verification: x′ = 1x + 0y + 1dx = x + dx) (Verification: y′ = 0x + 1y + 1dy = y + dy) (Homogenize: divide by 1 !!) P′ = T (dx, dy) P - Successive translations . P’’ (x’’,y’’) . P’ (x’,y’) T . P(x,y) P′ = T (dx 1 , dy 1 ) P, P′′ = T (dx 2 , dy 2 ) P′ Thus, P′′ = T (dx 2 , dy 2 )T (dx 1 , dy 1 ) P = T (dx 1 + dx 2 , dy 1 + dy 2 ) P 1 0 0 0 1 0 dx 2 1 dy 2 0 1 0 0 1 0 dx 1 1 dy 1 = 0 1 0 0 1 0 dx 1 + dx 2 dy 1 + dy 2 1 -8• Scaling using homogeneous coordinates x′ s x y′ = 0 1 0 0 sy 0 0 x 0 y 1 1 (Verify: x′ = s x x + 0y + 01 = s x x) (Verify: y′ = 0x + s y y + 01 = s y y) (homogenize: divide by 1 !!) P′ = S(s x , s y ) P - Successive scalings P′′ = S(s x 2 , s y2 ) P′ P′ = S(s x 1 , s y1 ) P, Thus, P′′ = S(s x 2 , s y2 )S(s x 1 , s y1 ) P = S(s x 1 s x 2 , s y1 s y2 ) P s x2 0 0 0 s y2 0 0 s x1 0 0 1 0 0 s x2 s x1 0 = 0 1 0 0 s y1 0 0 s y2 s y1 0 - Scaling about a fixed point x′ s x y′ = 0 1 0 x f (1 − s x ) x y f (1 − s y ) y 1 1 0 sy 0 - Decomposing the above transformation: 1 0 0 0 1 0 xf yf 1 sx 0 0 0 sy 0 0 1 0 0 1 0 0 1 0 −x f −y f 1 0 0 1 -9- • Rotation using homogeneous coordinates x′ cos( ) −sin( ) 0 x y′ = sin( ) cos( ) 0 y 0 1 1 1 0 P′ = R( ) P - Successive rotations P′ = R( 1 ) P, P′′ = R( 2 ) P′ Thus, P′′ = R( 1 )R( 2 ) P = R( 1 + 2) P - Rotation about an arbitrary point x′ cos( ) −sin( ) y′ = sin( ) cos( ) 0 1 0 x r (1 − cos( )) + y r sin( ) x y r (1 − cos( )) − x r sin( ) y 1 1 - Decomposing the above transformation: 1 0 0 0 1 0 x r cos( ) −sin( ) 0 1 y r sin( ) cos( ) 0 0 0 1 0 1 0 0 1 0 −x r −y r 1 -10- • Composition of a series of transformations - The transformation matrices of a series of transformations can be concatenated into a single transformation matrix - Example * Translate P 1 to origin * Perform scaling and rotation * Translate to P 2 M = T (x 2 , y 2 )R( )S(s x , s y )T (−x 1 , − y 1 ) - It is important to reserve the order in which a sequence of transformations is performed !! -11- • General form of transformation matrix x′ a11 y′ = a 21 1 0 a12 a22 0 a13 x a23 y 1 1 - Representing a sequence of transformations as a single transformation matrix is more efficient x′ = a11 x + a12 y + a13 y′ = a21 x + a22 y + a23 only 4 multiplications and 4 additions • Similarity transformations - Involve rotation, translation, scaling • Rigid-body transformations - Involve only translations and rotations - Preserve angles and lengths - General form of a rigid-body transformation matrix x′ r 11 y′ = r 21 1 0 r 12 r 22 0 tx x ty y 1 1 -12- Properties * The upper 2x2 submatrix is ortonormal u1 = (r 11 , r 12 ), u2 = (r 21 , r 22 ) u1 . u1 = ||u1 ||2 = r 11 2 + r 12 2 = 1 u2 . u2 = ||u2 ||2 = r 21 2 + r 22 2 = 1 u1 . u2 = r 11 r 21 + r 12 r 22 = 0 - Example: cos( ) −sin( ) 0 sin( ) cos( ) 0 0 1 0 u1 . u1 = cos( )2 + sin(− )2 = 1 u2 . u2 = cos( )2 + sin( )2 = 1 u1 . u2 = cos( )sin( ) − sin( )cos( ) = 0 • Affine transformations - Involve translations, rotations, scale, and shear - Preserve parallelism of lines but not lengths and angles -13• Shear transformations - Changes the shape of the object. - Shear along the x-axis: x′ = x + ay, y′ = y 1 SH x = 0 0 a 1 0 0 0 1 - Shear along the y-axis: x′ = x, y′ = bx + y 1 SH y = b 0 0 1 0 0 0 1
© Copyright 2026 Paperzz