380 likes | 665 Views
2D Geometric Transformations. Contents. Definition & Motivation 2D Geometric Transformation Translation Rotation Scaling Matrix Representation Homogeneous Coordinates Matrix Composition Composite Transformations Pivot-Point Rotation General Fixed-Point Scaling
E N D
Contents • Definition & Motivation • 2D Geometric Transformation • Translation • Rotation • Scaling • Matrix Representation • Homogeneous Coordinates • Matrix Composition • Composite Transformations • Pivot-Point Rotation • General Fixed-Point Scaling • Reflection and Shearing • Transformations Between Coordinate Systems
Geometric Transformation • Definition • Translation, Rotation, Scaling • Motivation – Why do we need geometric transformations in CG? • As a viewing aid • As a modeling tool • As an image manipulation tool
Example: 2D Geometric Transformation Modeling Coordinates World Coordinates
Example: 2D Scaling Modeling Coordinates Scale(0.3, 0.3) World Coordinates
Example: 2D Rotation Modeling Coordinates Scale(0.3, 0.3) Rotate(-90) World Coordinates
Example: 2D Translation Modeling Coordinates Scale(0.3, 0.3) Rotate(-90) Translate(5, 3) World Coordinates
Example: 2D Geometric Transformation Modeling Coordinates Again? World Coordinates
Example: 2D Geometric Transformation Modeling Coordinates Scale Translate Scale Rotate Translate World Coordinates
Basic 2D Transformations • Translation • Scale • Rotation • Shear
Basic 2D Transformations • Translation • Scale • Rotation • Shear Transformations can be combined (with simple algebra)
Basic 2D Transformations • Translation • Scale • Rotation • Shear
Basic 2D Transformations • Translation • Scale • Rotation • Shear
Basic 2D Transformations • Translation • Scale • Rotation • Shear
Basic 2D Transformations • Translation • Scale • Rotation • Shear
Matrix Representation • Represent a 2D Transformation by a Matrix • Apply the Transformation to a Point Transformation Matrix Point
Matrix Representation • Transformations can be combined by matrix multiplication Transformation Matrix Matrices are a convenient and efficient way to represent a sequence of transformations
2×2 Matrices • What types of transformations can be represented with a 2×2 matrix? 2D Identity 2D Scaling
2×2 Matrices • What types of transformations can be represented with a 2×2 matrix? 2D Rotation 2D Shearing
2×2 Matrices • What types of transformations can be represented with a 2×2 matrix? 2D Mirror over Y axis 2D Mirror over (0,0)
2×2 Matrices • What types of transformations can be represented with a 2×2 matrix? 2D Translation NO!! Only linear 2D transformations can be Represented with 2x2 matrix
2D Translation • 2D translation can be represented by a 3×3 matrix • Point represented with homogeneous coordinates
Basic 2D Transformations • Basic 2D transformations as 3x3 Matrices Translate Scale Rotate Shear
Homogeneous Coordinates • Add a 3rd coordinate to every 2D point • (x, y, w) represents a point at location (x/w, y/w) • (x, y, 0) represents a point at infinity • (0, 0, 0) Is not allowed y 2 (2, 1, 1) or (4, 2, 2) or (6, 3, 3) 1 x 1 2 Convenient Coordinate System to Represent Many Useful Transformations
Linear Transformations • Linear transformations are combinations of … • Scale • Rotation • Shear, and • Mirror • Properties of linear transformations • Satisfies: • Origin maps to origin • Lines map to lines • Parallel lines remain parallel • Ratios are preserved • Closed under composition
Affine Transformations • Affine transformations are combinations of • Linear transformations, and • Translations • Properties of affine transformations • Origin does not map to origin • Lines map to lines • Parallel lines remain parallel • Ratios are preserved • Closed under composition
Projective Transformations • Projective transformations… • Affine transformations, and • Projective warps • Properties of projective transformations • Origin does not map to origin • Lines map to lines • Parallel lines do not necessarily remain parallel • Ratios are not preserved • Closed under composition
Matrix Composition • Transformations can be combined by matrix multiplication • Efficiency with premultiplication • Matrix multiplication is associative
Matrix Composition • Rotate by around arbitrary point (a,b) • Scale by sx, sy around arbitrary point (a,b) (a,b) (a,b)
(xr,yr) (xr,yr) (xr,yr) (xr,yr) Pivot-Point Rotation Translate Rotate Translate
(xf,yf) (xf,yf) (xf,yf) (xf,yf) General Fixed-Point Scaling Translate Scale Translate
Reflection • Reflection with respect to the axis • x • y • xy y 1 y y 1 1’ 1’ 2 3 2 3 3’ 2 3’ 2 x x x 3 2’ 3’ 1 2 1’ x y xy
y y y y 1 2 3 x x x x 2’ 3’ 1’ Reflection • Reflection with respect to a Line • Clockwise rotation of 45 Reflection about the x axis Counterclockwise rotation of 45 y=x에 대한 반사
y y y y x x x x Shear • Converted to a parallelogram x’ = x + shx · y, y’ = y • Transformed to a shifted parallelogram (Y = Yref) x’ = x + shx ·(y-yref), y’ = y (1,1) (0,1) (2,1) (3,1) (0,0) (1,0) (0,0) (1,0) (Shx=2) (2,1) (1,1) (1,1) (0,1) (1/2,0) (3/2,0) (0,0) (1,0) (0,-1) (Shx=1/2, yref=-1)
y x Shear • Transformed to a shifted parallelogram (X = Xref) x’ = x, y’ = shy ·(x-xref) + y (1,2) (0,3/2) y (1,1) (0,1) (0,1/2) (1,1) x (0,0) (1,0) (-1,0) (Shy=1/2, xref=-1)