1 / 26

2D Transformations

2D Transformations. Dr. Aree Ali Mohammed Assistant Professor 2013-2014 3 rd Stage aree.ali@univsul.net. Objectives. Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation (rotation) Shapes (shear)

celina
Télécharger la présentation

2D Transformations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2D Transformations Dr. Aree Ali Mohammed Assistant Professor 2013-2014 3rd Stage aree.ali@univsul.net University of Sulaimani - School of Science - Computer Dept.

  2. Objectives • Given a 2D object, transformation is to change the object’s • Position (translation) • Size (scaling) • Orientation (rotation) • Shapes (shear) • Apply a sequence of matrix multiplication to the object vertices University of Sulaimani - School of Science - Computer Dept.

  3. What and Why Transformations • What is transformations? • The geometrical changes of an object from a current state to modified state. • Why the transformations is needed? • To manipulate the initially created object and to display the modified object without having to redraw it. University of Sulaimani - School of Science - Computer Dept.

  4. Types of Transformations • Geometric Transformations • Translation • Rotation • scaling • Linear (preserves parallel lines)‏ • Non-uniform scales, shears or skews • Projection (preserves lines)‏ • Perspective projection • Parallel projection • Non-linear (lines become curves)‏ • Twists, bends, warps, morphs,

  5. Translation Translate over vector (tx, ty) x’=x+ tx, y’=y+ ty or y P+T T P x

  6. Rotation y y P’ a P x x

  7. Scaling Schale with factor sxand sy: x’= sx x, y’= sy y or y P’ P Q’ Q x x

  8. Reflection I Reflext over x-axis: x’= x, y’= y or y x

  9. Reflection II x-axis y-axis University of Sulaimani - School of Science - Computer Dept.

  10. Reflection III line x=y Origin line x=-y University of Sulaimani - School of Science - Computer Dept.

  11. Shear Shear the y-as: x’=x+fy, y’=y or y x

  12. Homogeneous coordinates • Add an extra coordinate, W, to a point. • P(x,y,W). • Two sets of homogeneous coordinates represent the same point if they are a multiple of each other. • (2,5,3) and (4,10,6) represent the same point. • If W 0 , divide by it to get Cartesian coordinates of point (x/W,y/W,1). • If W=0, point is said to be at infinity.

  13. Put it all together University of Sulaimani - School of Science - Computer Dept.

  14. Example Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p (5,3)‏ (2,2)‏ Scale(2,2)‏ Translate(3,1)‏ (1,1)‏ (3,1)‏ (0,0)‏ (0,0)‏ Translate then Scale: p' = S ( T p ) = ST p (8,4)‏ (4,2)‏ Translate(3,1)‏ Scale(2,2)‏ (6,2)‏ (1,1)‏ (3,1)‏ (0,0)‏ Lecture 4

  15. 0 0 1 0 0 1 0 0 1 Example Non-commutative Composition Scale then Translate: p' = T ( S p ) = TS p 0 1 0 0 2 0 0 2 0 1 0 0 3 1 1 2 0 0 0 0 1 2 0 0 3 1 1 TS = = Translate then Scale: p' = S ( T p ) = ST p 0 2 0 1 0 2 2 0 0 0 1 0 3 1 2 0 6 2 ST = = Lecture 4

  16. Example How are transforms combined? Rotate then Translate (3,sqrt(2))‏ (0,sqrt(2))‏ (1,1)‏ Rotate 45 deg‏ Translate(3,0)‏ (0,0)‏ (0,0)‏ (3,0)‏ Translate then Rotate (1,1)‏ Translate(3,0)‏ (3/sqrt(2),3/sqrt(2))‏ Rotate 45 deg‏ (3,0)‏ (0,0)‏ (0,0)‏ Caution: matrix multiplication is NOT commutative! Lecture 4

  17. 0 0 1 Example Non-commutative Composition Rotate then Translate: p' = T ( R p ) = TR p 0 1 0 -1 0 0 1 0 0 3 1 1 0 0 0 3 1 1 -1 0 0 -1 0 0 -1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 TR = = Translate then Rotate: p' = R ( T p ) = RT p 0 1 -1 0 0 1 0 3 1 0 1 0 -1 3 1 -1 0 0 -1 0 0 -1 0 0 0 1 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 1 RT = = Lecture 4

  18. Inverse transformations

  19. Rotation around a point I R 1) 2) 3)

  20. Rotation around a point II R 1) 2) 3)

  21. Rotation around point III R 1) 2) 3)

  22. Rotation around point IV R 1) 2) 3)

  23. Exercises Translate a polygon with a coordinates A(2,5), B(7,10) and C(10,2) by three units in x-direction and 4 units in y-direction. A point is rotated counterclockwise by an angle of 45. Find the rotation matrix and the resultant point. Scale the polygon in example (1) by two units in x- and two units in y-direction. Give a 3x3 homogenous coordinate transformation matrix for each of the following translations: Shift the image to the right 3-units Shift the image up 2-units Move the image down 2/3 unit and left 4-units

  24. Homework I • I sat in the car, and realized the side mirror is 0.4m on my right and 0.3m in my front • I started my car and drove 5m forward, turned 30 degrees to right, moved 5m forward again, and turned 45 degrees to the right, and stopped • What is the position of the side mirror now, relative to where I was sitting in the beginning?

  25. Homework II A. Find the transformation matrix that transforms the given square ABCD to half its size with center still remaining at the same position. The coordinates of the square are: A(1,1), B(3,1), C(3,3), D(1,3) and center at (2,2). Also find the resultant coordinates of square. B. Find a transformation of triangle A(1,0), B(0,1), C(1,1) by Rotating 45° about the origin and then translating one unit in x and y direction. Translating one unit in x and y directions and then rotating 45° about the origin.

  26. Group Discussion

More Related