Lecture 5 2D Transformation
What is a transformation? In computer graphics an object can be transformed according to position, orientation and size. 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). Shearing reflection
Transformation Types of Transformation Geometric transformation: Object transformed related to their coordinate system or background. Coordinate transformation: coordinate system is transformed instead of object. classes of transformation Rigid body: Preserves distance and angle ( translation and rotation) Conformal: Preserves angles. (translation, rotation and uniform scaling Affine: Preserves parallelism, means lines remains lines. Example- translation, rotation, scaling, shear and reflection
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.
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.
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.
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.
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.
Scaling
Scaling
Scaling
One useful consequence of using matrices is that transformations that are combinations of transformations (remember that a local rotation is equivalent to a translation followed by a rotation followed by a translation) can be represented by multiplying the matrices together. Unfortunately, with the current set a matrices, this won t work because Equation 32 & Equation 33 are multiplications, whilst Equation 34 is an addition.
We can get round this by effectively including a fiddle factor and converting the matrices to use homogenous coordinates. What this actually means is that the addition necessary to perform translation can be achieved by multiplication. To convert our scheme of representation to homogenous coordinates we add an extra row to all point matrices and fill the extra position with a 1.
We can get round this by effectively including a fiddle factor and converting the matrices to use homogenous coordinates. What this actually means is that the addition necessary to perform translation can be achieved by multiplication. To convert our scheme of representation to homogenous coordinates we add an extra row to all point matrices and fill the extra position with a 1.
Combination of transformations using matrices When two matrices that represent different transformations are multiplied together, the resulting matrix represents the combined transformation. This leads to one of the main advantages of the matrix representation method: that a single matrix can be used to store the transformation that results from performing a sequence a transformations. i.e. we can concatenate transformations. This has obvious efficiency implications: in the case of repetitively applying the a series of transformations, the computer will need to do fewer calculations if the concatenation is available. A good example of this is the need to repeatedly spin an object about its centre (rotation about the local origin).
Identity Transformation
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.
Order of Transformation
Rotation around local origin
Rotation around local origin
Rotation around local origin
Composition and Decomposition of Transformations
Sheet
Sheet
Sheet
Sheet