Download presentation

Presentation is loading. Please wait.

Published byJaquelin Broome Modified over 2 years ago

1
Lecture 7 2D Transformation

2
What is a transformation? Exactly what it says - an operation that transforms or changes a shape (line, shape, drawing etc.) They are best understood graphically first. There are several basic ways you can change a shape: Translation (moving it somewhere else). Rotation (turning it round). Scaling (making it bigger or smaller).

3
Translation Essentially, we want to move the shape dx pixels along the x-axis and dy pixels up the y-axis. In fact all this means is moving each constituent point by dx and dy. To move a point in this manner, simply add the values of dx and dy to its existing coordinates. Example 15 shows what a translate() method of the Point2D class might look like.

4
Translation

5
Rotation ( about the origin) To rotate any shape about the origin requires rotating each of its individual points. To work out how this is done, consider the coordinates of a point before and after the rotation: Both points will lie on the perimeter of a circle of radius r with its center on the origin.

6
Rotation ( about the origin)

7
Scaling Scaling a shape simply means making a it bigger or smaller. We can specify how much bigger or small be 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 object we use a scale factor of 0.5.

8
Scaling Again, scaling of a shape is achieved by applying an operation to the individual points that make up the shape. In this case, the distance of a point from the origin changes by the scale factor. Simply multiplying the coordinates by the scale factor gives the new values of the coordinates.

9
Scaling Note that the scaling can be different in different directions: i.e. the x scale factor can be different to the y scale factor. By doing this we can stretch or squeeze a shape: Simply multiplying the coordinates by the scale factor gives the new values of the coordinates.

10
Identity Transformation

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

12
Rotation around local origin

13

14

15
Review

16
Exercises

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google