Upcoming SlideShare
×

# Hearn and Baker 2 D transformations

6,928 views

Published on

• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

### Hearn and Baker 2 D transformations

1. 1. 2D Geometric Transformations Taher S. Vijay Computer Academy August 2011
2. 2. Contents <ul><li>Definition & Motivation </li></ul><ul><li>2D Geometric Transformation </li></ul><ul><ul><li>Translation </li></ul></ul><ul><ul><li>Rotation </li></ul></ul><ul><ul><li>Scaling </li></ul></ul><ul><li>Matrix Representation </li></ul><ul><li>Homogeneous Coordinates </li></ul><ul><li>Matrix Composition </li></ul><ul><li>Composite Transformations </li></ul><ul><ul><li>Pivot-Point Rotation </li></ul></ul><ul><ul><li>General Fixed-Point Scaling </li></ul></ul><ul><ul><li>Reflection and Shearing </li></ul></ul><ul><ul><li>Transformations Between Coordinate Systems </li></ul></ul>Taher S. - VCA- 2011
3. 3. Geometric Transformation <ul><li>Definition </li></ul><ul><ul><li>Translation, Rotation, Scaling </li></ul></ul><ul><li>Motivation – Why do we need geometric transformations in CG? </li></ul><ul><ul><li>As a viewing aid </li></ul></ul><ul><ul><li>As a modeling tool </li></ul></ul><ul><ul><li>As an image manipulation tool </li></ul></ul>Taher S. - VCA- 2011
4. 4. Example: 2D Geometric Transformation Taher S. - VCA- 2011 Modeling Coordinates World Coordinates
5. 5. Example: 2D Scaling Taher S. - VCA- 2011 Modeling Coordinates World Coordinates Scale(0.3, 0.3)
6. 6. Example: 2D Rotation Taher S. - VCA- 2011 Modeling Coordinates Scale(0.3, 0.3) Rotate(-90) World Coordinates
7. 7. Example: 2D Translation Taher S. - VCA- 2011 Modeling Coordinates Scale(0.3, 0.3) Rotate(-90) Translate(5, 3) World Coordinates
8. 8. Example: 2D Geometric Transformation Taher S. - VCA- 2011 Modeling Coordinates World Coordinates Again?
9. 9. Example: 2D Geometric Transformation Taher S. - VCA- 2011 Modeling Coordinates World Coordinates Scale Translate Scale Rotate Translate
10. 10. Basic 2D Transformations <ul><li>Translation </li></ul><ul><li>Scale </li></ul><ul><li>Rotation </li></ul><ul><li>Shear </li></ul>Taher S. - VCA- 2011
11. 11. Basic 2D Transformations <ul><li>Translation </li></ul><ul><li>Scale </li></ul><ul><li>Rotation </li></ul><ul><li>Shear </li></ul>Taher S. - VCA- 2011 Transformations can be combined (with simple algebra)
12. 12. Basic 2D Transformations <ul><li>Translation </li></ul><ul><li>Scale </li></ul><ul><li>Rotation </li></ul><ul><li>Shear </li></ul>Taher S. - VCA- 2011
13. 13. Basic 2D Transformations <ul><li>Translation </li></ul><ul><li>Scale </li></ul><ul><li>Rotation </li></ul><ul><li>Shear </li></ul>Taher S. - VCA- 2011
14. 14. Basic 2D Transformations <ul><li>Translation </li></ul><ul><li>Scale </li></ul><ul><li>Rotation </li></ul><ul><li>Shear </li></ul>Taher S. - VCA- 2011
15. 15. Basic 2D Transformations <ul><li>Translation </li></ul><ul><li>Scale </li></ul><ul><li>Rotation </li></ul><ul><li>Shear </li></ul>Taher S. - VCA- 2011
16. 16. Matrix Representation <ul><li>Represent a 2D Transformation by a Matrix </li></ul><ul><li>Apply the Transformation to a Point </li></ul>Taher S. - VCA- 2011 Transformation Matrix Point
17. 17. Matrix Representation <ul><li>Transformations can be combined by matrix multiplication </li></ul>Taher S. - VCA- 2011 Matrices are a convenient and efficient way to represent a sequence of transformations Transformation Matrix
18. 18. 2×2 Matrices <ul><li>What types of transformations can be represented with a 2×2 matrix? </li></ul><ul><li>2D Identity </li></ul><ul><li>2D Scaling </li></ul>Taher S. - VCA- 2011
19. 19. 2×2 Matrices <ul><li>What types of transformations can be represented with a 2×2 matrix? </li></ul><ul><li>2D Rotation </li></ul><ul><li>2D Shearing </li></ul>Taher S. - VCA- 2011
20. 20. 2×2 Matrices <ul><li>What types of transformations can be represented with a 2×2 matrix? </li></ul><ul><li>2D Mirror over Y axis </li></ul><ul><li>2D Mirror over (0,0) </li></ul>Taher S. - VCA- 2011
21. 21. 2×2 Matrices <ul><li>What types of transformations can be represented with a 2×2 matrix? </li></ul><ul><li>2D Translation </li></ul>Taher S. - VCA- 2011 Careful!
22. 22. Homogeneous Coordinates <ul><li>Add a 3rd coordinate to every 2D point </li></ul><ul><ul><li>(x, y, w) represents a point at location (x/w, y/w) </li></ul></ul><ul><ul><li>(x, y, 0) represents a point at infinity </li></ul></ul><ul><ul><li>(0, 0, 0) Is not allowed </li></ul></ul>Taher S. - VCA- 2011 1 2 1 2 x y (2, 1, 1) or (4, 2, 2) or (6, 3, 3) Convenient Coordinate System to Represent Many Useful Transformations
23. 23. 2D Translation <ul><li>2D translation can be represented by a 3×3 matrix </li></ul><ul><ul><li>Point represented with homogeneous coordinates </li></ul></ul>Taher S. - VCA- 2011
24. 24. Basic 2D Transformations <ul><li>Basic 2D transformations as 3x3 Matrices </li></ul>Taher S. - VCA- 2011 Translate Shear Scale Rotate
25. 25. Linear Transformations <ul><li>Linear transformations are combinations of … </li></ul><ul><ul><li>Scale </li></ul></ul><ul><ul><li>Rotation </li></ul></ul><ul><ul><li>Shear, and </li></ul></ul><ul><ul><li>Mirror </li></ul></ul><ul><li>Properties of linear transformations </li></ul><ul><ul><li>Satisfies: </li></ul></ul><ul><ul><li>Origin maps to origin </li></ul></ul><ul><ul><li>Lines map to lines </li></ul></ul><ul><ul><li>Parallel lines remain parallel </li></ul></ul><ul><ul><li>Ratios are preserved </li></ul></ul><ul><ul><li>Closed under composition </li></ul></ul>Taher S. - VCA- 2011
26. 26. Affine Transformations <ul><li>Affine transformations are combinations of </li></ul><ul><ul><li>Linear transformations, and </li></ul></ul><ul><ul><li>Translations </li></ul></ul><ul><li>Properties of affine transformations </li></ul><ul><ul><li>Origin does not map to origin </li></ul></ul><ul><ul><li>Lines map to lines </li></ul></ul><ul><ul><li>Parallel lines remain parallel </li></ul></ul><ul><ul><li>Ratios are preserved </li></ul></ul><ul><ul><li>Closed under composition </li></ul></ul>Taher S. - VCA- 2011
27. 27. Projective Transformations <ul><li>Projective transformations… </li></ul><ul><ul><li>Affine transformations, and </li></ul></ul><ul><ul><li>Projective warps </li></ul></ul><ul><li>Properties of projective transformations </li></ul><ul><ul><li>Origin does not map to origin </li></ul></ul><ul><ul><li>Lines map to lines </li></ul></ul><ul><ul><li>Parallel lines do not necessarily remain parallel </li></ul></ul><ul><ul><li>Ratios are not preserved </li></ul></ul><ul><ul><li>Closed under composition </li></ul></ul>Taher S. - VCA- 2011
28. 28. Matrix Composition <ul><li>Transformations can be combined by matrix multiplication </li></ul><ul><li>Efficiency with premultiplication </li></ul><ul><ul><li>Matrix multiplication is associative </li></ul></ul>Taher S. - VCA- 2011
29. 29. Matrix Composition <ul><li>Rotate by  around arbitrary point (a,b) </li></ul><ul><li>Scale by sx, sy around arbitrary point (a,b) </li></ul>Taher S. - VCA- 2011 (a,b) (a,b)
30. 30. Pivot-Point Rotation Taher S. - VCA- 2011 Translate Rotate Translate (x r ,y r ) (x r ,y r ) (x r ,y r ) (x r ,y r )
31. 31. General Fixed-Point Scaling Taher S. - VCA- 2011 Translate Scale Translate (x f ,y f ) (x f ,y f ) (x f ,y f ) (x f ,y f )
32. 32. Reflection <ul><li>Reflection with respect to the axis </li></ul><ul><li>• x • y • xy </li></ul>Taher S. - VCA- 2011 y x x y 1 3 2 1’ 3’ 2’ x y 1 3 2 1’ 3’ 2 x y 3 1’ 3’ 2 1 2 xy
33. 33. Reflection Taher S. - VCA- 2011 <ul><li>Reflection with respect to a Line </li></ul><ul><li>Clockwise rotation of 45  Reflection about the x axis  Counterclockwise rotation of 45 </li></ul>y=x x y 1 3 2 1’ 3’ 2’ x y x y x y
34. 34. Shear <ul><li>Converted to a parallelogram </li></ul><ul><li> </li></ul><ul><li>x’ = x + sh x · y, y’ = y </li></ul><ul><li>Transformed to a shifted parallelogram </li></ul><ul><ul><li>(Y = Yref) </li></ul></ul><ul><li> </li></ul><ul><li>x’ = x + sh x · ( y-y ref ), y’ = y </li></ul>Taher S. - VCA- 2011 x ( Sh x =2 ) ( Sh x =1/2, y ref =-1 ) (0,0) (1,0) (1,1) (0,1) ( 0,0 ) ( 1,0 ) ( 1,1 ) (0,1) (0,0) (1,0) (3,1) (2,1) ( 1/2,0 ) ( 3/2,0 ) ( 2,1 ) ( 1,1 ) (0,-1) x y x y x y x y
35. 35. Shear <ul><li>Transformed to a shifted parallelogram </li></ul><ul><ul><li>(X = Xref) </li></ul></ul><ul><li>x’ = x, y’ = sh y · ( x-x ref ) + y </li></ul>Taher S. - VCA- 2011 ( Sh y =1/2, x ref =-1 ) x y (-1,0) ( 0,0 ) ( 1,0 ) ( 1,1 ) ( 0,1 ) ( 0,1/2 ) ( 1,1 ) ( 1,2 ) ( 0,3/2 ) x y