Graphics 2 D Geometric Transformations cgvr korea ac

  • Slides: 36
Download presentation
Graphics 2 D Geometric Transformations 고려대학교 그래픽스 연구실 cgvr. korea. ac. kr 1 Graphics

Graphics 2 D Geometric Transformations 고려대학교 그래픽스 연구실 cgvr. korea. ac. kr 1 Graphics Lab @ Korea University

Contents CGVR Definition & Motivation n 2 D Geometric Transformation n Translation n Rotation

Contents CGVR Definition & Motivation n 2 D Geometric Transformation n Translation n Rotation n Scaling n Matrix Representation n Homogeneous Coordinates n Matrix Composition n Composite Transformations n Pivot-Point Rotation n General Fixed-Point Scaling n Reflection and Shearing n Transformations Between Coordinate Systems n cgvr. korea. ac. kr 2 Graphics Lab @ Korea University

Geometric Transformation n CGVR Definition 물체의 좌표를 바꾸는 것 n Translation, Rotation, Scaling n

Geometric Transformation n CGVR Definition 물체의 좌표를 바꾸는 것 n Translation, Rotation, Scaling n n Motivation – Why do we need geometric transformations in CG? As a viewing aid n As a modeling tool n As an image manipulation tool n cgvr. korea. ac. kr 3 Graphics Lab @ Korea University

Example: 2 D Geometric Transformation CGVR Modeling Coordinates World Coordinates cgvr. korea. ac. kr

Example: 2 D Geometric Transformation CGVR Modeling Coordinates World Coordinates cgvr. korea. ac. kr 4 Graphics Lab @ Korea University

Example: 2 D Scaling CGVR Modeling Coordinates Scale(0. 3, 0. 3) World Coordinates cgvr.

Example: 2 D Scaling CGVR Modeling Coordinates Scale(0. 3, 0. 3) World Coordinates cgvr. korea. ac. kr 5 Graphics Lab @ Korea University

Example: 2 D Rotation CGVR Modeling Coordinates Scale(0. 3, 0. 3) Rotate(-90) World Coordinates

Example: 2 D Rotation CGVR Modeling Coordinates Scale(0. 3, 0. 3) Rotate(-90) World Coordinates cgvr. korea. ac. kr 6 Graphics Lab @ Korea University

Example: 2 D Translation CGVR Modeling Coordinates Scale(0. 3, 0. 3) Rotate(-90) Translate(5, 3)

Example: 2 D Translation CGVR Modeling Coordinates Scale(0. 3, 0. 3) Rotate(-90) Translate(5, 3) World Coordinates cgvr. korea. ac. kr 7 Graphics Lab @ Korea University

Example: 2 D Geometric Transformation CGVR Modeling Coordinates Again? World Coordinates cgvr. korea. ac.

Example: 2 D Geometric Transformation CGVR Modeling Coordinates Again? World Coordinates cgvr. korea. ac. kr 8 Graphics Lab @ Korea University

Example: 2 D Geometric Transformation Modeling Coordinates CGVR Scale Translate Scale Rotate Translate World

Example: 2 D Geometric Transformation Modeling Coordinates CGVR Scale Translate Scale Rotate Translate World Coordinates cgvr. korea. ac. kr 9 Graphics Lab @ Korea University

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation n

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation n Shear n n cgvr. korea. ac. kr 10 Graphics Lab @ Korea University

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation Transformations

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation Transformations can be combined (with simple algebra) n n n Shear n n cgvr. korea. ac. kr 11 Graphics Lab @ Korea University

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation n

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation n Shear n n cgvr. korea. ac. kr 12 Graphics Lab @ Korea University

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation n

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation n Shear n n cgvr. korea. ac. kr 13 Graphics Lab @ Korea University

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation n

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation n Shear n n cgvr. korea. ac. kr 14 Graphics Lab @ Korea University

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation n

Basic 2 D Transformations n CGVR Translation n Scale n n n Rotation n Shear n n cgvr. korea. ac. kr 15 Graphics Lab @ Korea University

Matrix Representation CGVR n Represent a 2 D Transformation by a Matrix n Apply

Matrix Representation CGVR n Represent a 2 D Transformation by a Matrix n Apply the Transformation to a Point Transformation Matrix cgvr. korea. ac. kr 16 Point Graphics Lab @ Korea University

Matrix Representation n CGVR Transformations can be combined by matrix multiplication Transformation Matrix Matrices

Matrix Representation n CGVR Transformations can be combined by matrix multiplication Transformation Matrix Matrices are a convenient and efficient way to represent a sequence of transformations cgvr. korea. ac. kr 17 Graphics Lab @ Korea University

2× 2 Matrices n CGVR What types of transformations can be represented with a

2× 2 Matrices n CGVR What types of transformations can be represented with a 2× 2 matrix? 2 D Identity 2 D Scaling cgvr. korea. ac. kr 18 Graphics Lab @ Korea University

2× 2 Matrices n CGVR What types of transformations can be represented with a

2× 2 Matrices n CGVR What types of transformations can be represented with a 2× 2 matrix? 2 D Rotation 2 D Shearing cgvr. korea. ac. kr 19 Graphics Lab @ Korea University

2× 2 Matrices n CGVR What types of transformations can be represented with a

2× 2 Matrices n CGVR What types of transformations can be represented with a 2× 2 matrix? 2 D Mirror over Y axis 2 D Mirror over (0, 0) cgvr. korea. ac. kr 20 Graphics Lab @ Korea University

2× 2 Matrices n CGVR What types of transformations can be represented with a

2× 2 Matrices n CGVR What types of transformations can be represented with a 2× 2 matrix? 2 D Translation NO!! Only linear 2 D transformations can be Represented with 2 x 2 matrix cgvr. korea. ac. kr 21 Graphics Lab @ Korea University

2 D Translation n CGVR 2 D translation can be represented by a 3×

2 D Translation n CGVR 2 D translation can be represented by a 3× 3 matrix n Point represented with homogeneous coordinates cgvr. korea. ac. kr 22 Graphics Lab @ Korea University

Basic 2 D Transformations n CGVR Basic 2 D transformations as 3 x 3

Basic 2 D Transformations n CGVR Basic 2 D transformations as 3 x 3 Matrices cgvr. korea. ac. kr Translate Scale Rotate Shear 23 Graphics Lab @ Korea University

Homogeneous Coordinates n CGVR Add a 3 rd coordinate to every 2 D point

Homogeneous Coordinates n CGVR Add a 3 rd coordinate to every 2 D point (x, y, w) represents a point at location (x/w, y/w) n (x, y, 0) represents a point at infinity n (0, 0, 0) Is not allowed n y 2 (2, 1, 1) or (4, 2, 2) or (6, 3, 3) 1 1 2 x Convenient Coordinate System to Represent Many Useful Transformations cgvr. korea. ac. kr 24 Graphics Lab @ Korea University

Linear Transformations n CGVR Linear transformations are combinations of … Scale n Rotation n

Linear Transformations n CGVR Linear transformations are combinations of … Scale n Rotation n Shear, and n Mirror n n Properties of linear transformations n n n Satisfies: Origin maps to origin Lines map to lines Parallel lines remain parallel Ratios are preserved Closed under composition cgvr. korea. ac. kr 25 Graphics Lab @ Korea University

Affine Transformations n CGVR Affine transformations are combinations of Linear transformations, and n Translations

Affine Transformations n CGVR Affine transformations are combinations of Linear transformations, and n Translations n n Properties of affine transformations n n n Origin does not map to origin Lines map to lines Parallel lines remain parallel Ratios are preserved Closed under composition cgvr. korea. ac. kr 26 Graphics Lab @ Korea University

Projective Transformations n CGVR Projective transformations… Affine transformations, and n Projective warps n n

Projective Transformations n CGVR Projective transformations… Affine transformations, and n Projective warps n n Properties of projective transformations n n n Origin does not map to origin Lines map to lines Parallel lines do not necessarily remain parallel Ratios are not preserved Closed under composition cgvr. korea. ac. kr 27 Graphics Lab @ Korea University

Matrix Composition CGVR n Transformations can be combined by matrix multiplication n Efficiency with

Matrix Composition CGVR n Transformations can be combined by matrix multiplication n Efficiency with premultiplication n Matrix multiplication is associative cgvr. korea. ac. kr 28 Graphics Lab @ Korea University

Matrix Composition n CGVR Rotate by around arbitrary point (a, b) n Scale by

Matrix Composition n CGVR Rotate by around arbitrary point (a, b) n Scale by sx, sy around arbitrary point (a, b) n (a, b) cgvr. korea. ac. kr 29 Graphics Lab @ Korea University

Pivot-Point Rotation (xr, yr ) Translate cgvr. korea. ac. kr 30 Rotate CGVR (xr,

Pivot-Point Rotation (xr, yr ) Translate cgvr. korea. ac. kr 30 Rotate CGVR (xr, yr ) Translate Graphics Lab @ Korea University

General Fixed-Point Scaling (xr, yr ) Translate cgvr. korea. ac. kr 31 Scale (xr,

General Fixed-Point Scaling (xr, yr ) Translate cgvr. korea. ac. kr 31 Scale (xr, yr ) CGVR (xr, yr ) Translate Graphics Lab @ Korea University

General Scaling Directions n CGVR Converted to a parallelogram y y (1/2, 3/2) (0,

General Scaling Directions n CGVR Converted to a parallelogram y y (1/2, 3/2) (0, 1) (2, 2) (1, 1) (3/2, 1/2) (0, 0) (1, 0) x x (0, 0) Scale S 2=2, S 1=1 y s 2 xs 1 x축으로부터 경사진 방향에 신축 적용 cgvr. korea. ac. kr 32 Graphics Lab @ Korea University

Reflection n CGVR Reflection with respect to the axis • x축에 대한 반사 y

Reflection n CGVR Reflection with respect to the axis • x축에 대한 반사 y • 1 1 2 3 2’ 3’ 2 y 3 xy축(원점)에 대한 y 1’ 3’ x 2 x 1’ 3’ 3 1 2 x 2 1’ x축에 대한 반사 cgvr. korea. ac. kr • y축에 대한 반사 33 y축에 대한 반사 원점에 대한 반사 Graphics Lab @ Korea University

Reflection n CGVR Reflection with respect to a Line y x y=x 에 대한

Reflection n CGVR Reflection with respect to a Line y x y=x 에 대한 반사 n Clockwise rotation of 45 Reflection about the x axis Counterclockwise rotation of 45 y y x 1 y 2 3 2’ 3’ x x 1’ cgvr. korea. ac. kr 34 Graphics Lab @ Korea University

Shear n CGVR Converted to a parallelogram x’ = x + shx · y,

Shear n CGVR Converted to a parallelogram x’ = x + shx · y, y (0, 1) (1, 1) (0, 0) (1, 0) y (2, 1) x (0, 0) (1, 0) (3, 1) x y’ = y x축으로 밀림 (Shx=2) n Transformed to a shifted parallelogram (Y = Yref) y x’ = x + shx · (y-yref), cgvr. korea. ac. kr 35 y’ = y (0, 1) (1, 1) (0, 0) (1, 0) y (1, 1) (1/2, 0) x (2, 1) (3/2, 0)x (0, -1) 선분에 대한 밀림 (Shx=1/2, yref=-1) Graphics Lab @ Korea University

Shear n CGVR Transformed to a shifted parallelogram (X = Xref) y x’ =

Shear n CGVR Transformed to a shifted parallelogram (X = Xref) y x’ = x, (0, 1) (1, 1) (0, 0) (1, 0) (0, 3/2) (1, 2) (0, 1/2) (1, 1) y x (-1, 0) x y’ = shy · (x-xref) + y 선분에 대한 밀림 (Shy=1/2, xref=-1) cgvr. korea. ac. kr 36 Graphics Lab @ Korea University