1 / 20

2D Transformations

2D Transformations. Mohammad Sharaf. What is a transformation?. A transformation is an operation that transforms or changes a shape (line, drawing etc.) There are several basic ways you can change a shape: translation (moving it) rotation (turning it round)

roth-golden
Download Presentation

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 Mohammad Sharaf

  2. What is a transformation? • A transformation is an operation that transforms or changes a shape (line, drawing etc.) • There are several basic ways you can change a shape: • translation (moving it) • rotation (turning it round) • scaling (making it bigger or smaller). • There are others, but we’ll worry about them later.

  3. Translate Shear Rotate Scale 2D Geometrical Transformations

  4. Translation • Consider the arrow below. We may want to move it from position A to position B. y B dy A x dx

  5. P’(x’,y’) dy P(x,y) dx Translate Points We can translate points in the (x, y) plane to new positions by adding translation amounts to the coordinates of the points. For each point P(x, y) to be moved by dx units parallel to the x axis and by dy units parallel to the y axis, to the new point P’(x’, y’ ). The translation has the following form:

  6. Translating a line or shape • To translate a line, simply translate both of its end points. • Translating a shape therefore, simply translate all of the points. • The same applies for all transformations.

  7. P(x,y) y sy y P’(x’,y’) sx x x Scale Points • Points can be scaled (stretched) by sx along the x axis and by sy along the y axis into the new points by the multiplications: • We can specify how much bigger or smaller by means of a “scale factor” • To double the size of an object we use a scale factor of 2, to half the size of an obejct we use a scale factor of 0.5

  8. P y l  x O Rotate Points We first review the idea of sin and cos for a given angle  : Useful formulas:

  9. P’(x’,y’) P(x,y) y l y’   O x’ x Rotate Points (cont.) Points can be rotated through an angle  about the origin:

  10. Identity transformations • Some transformations lead to no change in the shape/drawing • Translate(0,0) • Rotate(0) • Scale(1,1)

  11. Order of transformations • The order in which transformations are applied to a shape is important. • Performing a translation followed by a rotation, will give an entirely different drawing to a performing the rotation followed by the same translation.

  12. Order of transformations

  13. Order of transformations

  14. Rotation around local origin • At the moment, our rotation is centred around the origin. What is often required is to spin the shape in its original location (in-situ)

  15. Rotation around local origin • This can be achieved by combining two of our existing transformations: Translate the shape to the origin, rotate it the required amount about the origin and translate it back to where it was.

  16. y dx dy x Local rotation

  17. Local rotation

  18. y x y Local rotation

  19. +dx +dy x Local rotation

  20. Summary • So we have looked at simple transformation of points/lines etc. • Next we will look at transformations using matrices.

More Related