E N D
Module 3 2D Geometric Transformations
2-D Geometric Transformations • In order to manipulate an object in 2-D space, we must apply various transformations functions to the object. • This allows us to change the position, size and orientation of the objects. • There are two complementary points of view for describing object movement. • Geometric Transformation: The object itself is moved relative to a stationary coordinate system or background. • Coordinate Transformation: The object is held stationary while the coordinate system is moved relative to the object.
Basic Transformations • Transformation: Making changes or allowing modification to the picture or image is called transformation. • Types of basic transformations: 1. Translation Transformations 2. Rotation Transformations 3. Scaling Transformations 4. Reflection Transformation 5. Shear Transformation
From the above figure, you can write that − • X’ = X + tx Y’ = Y + ty The pair (tx, ty) is called the translation vector or shift vector. The above equations can also be represented using the column vectors. P=[X]/[Y] p' = [X′]/[Y′] T = [tx]/[ty] We can write it as − P’ = P + T Translation A translation moves an object to a different position on the screen. You can translate a point in 2D by adding translation coordinate (tx, ty) to the original coordinate X,Y to get the new coordinate X′,Y′
Rotation In rotation, we rotate the object at particular angle θ theta from its origin. From the following figure, we can see that the point P (X,Y) is located at angle φ from the horizontal X coordinate with distance r from the origin. Let us suppose you want to rotate it at the angle θ. After rotating it to a new location, you will get a new point P’(X′,Y′)
Scaling To change the size of an object, scaling transformation is used. In the scaling process, you either expand or compress the dimensions of the object. Scaling can be achieved by multiplying the original coordinates of the object with the scaling factor to get the desired result. Let us assume that the original coordinates are X,Y the scaling factors are (SX, SY), and the produced coordinates are X′,Y′. This can be mathematically represented as shown below − X' = X . SX and Y' = Y . SY The scaling factor SX, SY scales the object in X and Y direction respectively. The above equations can also be represented in matrix form as below − or P’ = P . S Where S is the scaling matrix. The scaling process is shown in the following figure If we provide values less than 1 to the scaling factor S, then we can reduce the size of the object. If we provide values greater than 1, then we can increase the size of the object.
Reflection • A reflection is a transformation that produces a mirror image of an object. • Since the reflection P’ of an object point P is located the same distance from the mirror as P. (i) The mirror reflection transformation Mx about the x-axis is given by: P’ = Mx (P) where, x’ = x & y’ = -y It can be represented in matrix form as
(ii) The mirror reflection transformation My about y-axis is given by: P’ = My(P) where, x’ = -x & y’ = y It can be represented in matrix form as:
Shearing • The shear transformation distorts an object by scaling one coordinate using the other.
An x-direction shear relative to the x axis is produced with the transformation matrix which transforms coordinate position as • Similarly, a y-direction shear relative to the y axis is produced with the transformation matrix • which transforms coordinate position as y’ = x . Shy + y , x’ = x x’ = x + Shx . y , y’ = y
Example: Take (x,y) = (1,1) & Shx = 2 X’ = x + Shx . Y y’ = y = 1 + 2 . 1 y’ = 1 = 1 + 2 = 3 (x’, y’) = (3,1)
Homogenous Coordinates • The rotation of a point, straight line or an entire image on the screen, about a point other than origin, is achieved by first moving the image until the point of rotation occupies the origin, then performing rotation, then finally moving the image to its original position. • The moving of an image from one place to another in a straight line is called a translation. A translation may be done by adding or subtracting to each point, the amount, by which picture is required to be shifted. • Translation of point by the change of coordinate cannot be combined with other transformation by using simple matrix application. Such a combination is essential if we wish to rotate an image about a point other than origin by translation, rotation again translation. • To combine these three transformations into a single transformation, homogeneous coordinates are used. In homogeneous coordinate system, two-dimensional coordinate positions (x, y) are represented by triple-coordinates.
Composite Transformation • A number of transformations or sequence of transformations can be combined into single one called as composition. The resulting matrix is called as composite matrix. The process of combining is called as concatenation. • Example 1:Suppose we want to perform rotation about an arbitrary point, then we can perform it by the sequence of three transformations. • Translation • Rotation • Reverse Translation • The ordering sequence of these numbers of transformations must not be changed. If a matrix is represented in column form, then the composite transformation is performed by multiplying matrix in order from right to left side. The output obtained from the previous matrix is multiplied with the new coming matrix.
Step1: The object is kept at its position as in fig (a) Step2: The object is translated so that its center coincides with the origin as in fig (b) Step3: Scaling of an object by keeping the object at origin is done in fig (c) Step4: Again translation is done. This second translation is called a reverse translation. It will position the object at the origin location.
Example 2:For it first of all rotate function is used. Sequences of steps are given below for rotating an object about origin. • Translate object to origin from its original position as shown in fig (b) • Rotate the object about the origin as shown in fig (c). • Translate the object to its original position from origin. It is called as reverse translation as shown in fig (d).