Breaking News
You are here: Home / Notes / SEM-6 / Computer Graphics / Transformations

Transformations

Transformations

Transformations

Transformations

In most of the application of graphics, the objects or images are required to be manipulated or altered. To add reality or feel like reality, many times these objects are needed to be moved, rotated or even in some applications, enlarged or reduced. This alteration or manipulation processes of objects is called images or objects transformation.

Basic Transformation

There are three basic actions or movements, moving, scaling and rotating which are widely used in the graphics applications. These movements are performed through some basic geometry. Since these transformations are performed using geometry, they are also known asgeometric transformation. There are three basic transformations, translation, scaling and rotation.

1.     Scaling: Scaling transformation is used to alter the size of the given objects. The alteration of size of the object is defined by the factor. The scale factor specifies how big or small the object should be after alteration. To alter the size of any object in the horizontal direction the scale factor Sx is used, whereas alter in the vertical direction the scale factor Sy is used.

The scaling transformation is performed simply by multiplying the (x, y) coordinate values by scale factors of horizontal and vertical directions, that is Sx and Sy respectively. Mathematical representation of transformation of original coordinates (x, y) into scaled transformed coordinates (x’, y’) is,

X’ = Sx X  and Y’= SyY

To scale a polygon, this transformation is performed on all the vertices of a given polygon. To enlarge or double the size of the polygon horizontally, the X coordinate of all the vertices need to be multiplied by 2. That is in this case the X Scale factor Sx = 2. Similarly, if we want to reduce the size of object vertically by half, the Y-coordinates of the vertices are multiplied by the Y-scale factor Sy = (1/2).

[ X ‘ Y’ ] = [ X Y ] [Sx 0 ] [0 Sy]

Which is equivalent to

P’ = P . S

Where P’ is a 1 * 2 row matrix of scaled coordinates, P is again a 1 * 2 row matrix of original coordinates, and S is a 2 * 2 scaling transformation matrix. Since Sx and Sy are scale factors they are always positive. Also, the values of Sx and Sy greater than 1 will enlarge the object in horizontal or vertical direction respectively whereas their values between 0 and 1 will reduce the object in the respective directions. Obviously, if the values of Sx and Sy are equal to 1, then the scaling matrix will turn into a unit matrix and therefore there will be no change in the scaled coordinates. When the object is altered with same scale factor for both the horizontal and vertical directions, i.e. Sx = Sy, the scaling transformation is known uniform scaling transformation otherwise it is called differential scaling transformation as illustrated in following figure.

Scaling

 

Thus, to perform scaling on an object, the scaling transformation is performed on all the vertices of the object. Here it will be interesting and important to observe that by doing this; the position of the altered object will be changed along the transformation. But almost all the graphical application need to keep the object at its original position or some pre-specified position (Xk, Yk) even after scale transformation. This scaling transformation relative to a fixed to a point (Xk, Yk) is done by the following set of equations.

X’ = X Sx + ( Xk – Xk Sx)

Y’ = Y Sy + ( Yk – Yk Sy)

OR

X’ = X Sx + Xk (1 – Sx)

Y’ = Y Sy + Yk (1 – Sy)

In the matrix form, this equation can be represented as follows:

[ X’ Y’ ] = [ X Y ] [ Sx 0 ] + [ Xk (1 – Sx) Yk (1 – Sy) ] [ 0 Sy ]

Where Xk (1 – Sx)  and Yk (1 – Sy) are constant terms which are added to the original scale  transformation as shown in this equation:

[ X’ Y’ ] = [ X Y ] [ Sx 0 ] [ 0 Sy ]

The above example will work with the objects which are defined by the straight lines. Bit when the objects or shapes like circles and ellipses are there, the above mentioned equation or matrices will not work. For scaling these types of objects, the scaling transformation is performed on their parameters.

Ex. On the radius for a circle and on the semi-major and semi-minor axes for and ellipses.

2.     Translation: Translation an object means moving and objects from one place to another. Translation of an object is possible in any one of the following directions:

(1)  Translation of an object in the horizontal direction, which is translation parallel to X-axis.

(2)  Translation of object in the vertical direction, which is translation parallel to Y-axis.

(3)   Translation of object in the vertical and horizontal direction, simultaneously.

It is very simple to understand translation. Suppose we want to move a point (x, y) in the horizontal direction, that is in direction parallel X-axis by Tx units, then this movement can be obtain by simple adding Tx to X-coordinate. The coordinate of points after translation will be,

X’ = X + Tx

Y’ = Y

Similarly, to move a point (x, y) in the vertical direction that is in the direction parallel to Y-axis Ty is added to the Y-coordinate value. In this case, the coordinate of translation point will be,

X’ = X

Y’ = Y + Ty

In the above equation, Tx and Ty are translation for translating a point in the X-direction and the Y-direction respectively. The general form translation is,

(X’ Y’) = (X + Tx, y + Ty) or

[X’ Y’] = [X Y] + [Tx Ty]            or

P’ = P + T

Where P’ is a 1 * 2 row matrix of coordinates of the translation point, P is the 1 * 2 row factors.

Translation

 

Translation transformation is a rigid-body transformation. A transformation is called a rigid-body transformation if the Euclidean distance between any two coordinates remains unchanged by the transformation.

Here also translation is performed on each and every vertex of an object to translate the entire object. After finding all the new vertices, the object is redrawn by new derived vertices. Translation of other object like circles and ellipses is performed by translating their parameters. For e.g. center point of a circle. Translation is performed after scaling is done on the object to put it back on the desired place by using the equation of:

[ X’ Y’] = [ X Y ] [ Sx 0 ] + [ Xk (1 – Sx) Yk (1 – Sy)] [ 0 Sy]

3.     Rotation: Rotation is the most exciting transformation. This transformation moves an object on a circular path about an origin. This transformation requires two major parameters that are dimension and angle of rotation. Any given object can be rotated either in clockwise direction or in anti-clockwise direction by a given angle θ.

Rotation

In the 2-dimensional rotation as, mentioned earlier, the object is rotated around a fixed point – either an original or a given point (This point is called as rotation point.) Therefore, this rotation can also be declared as rotation around an axis which is called as rotation axis. Essentially, this rotation axis passes through rotation point and is perpendicular to the XY-plane as illustrated in figure.

Rotation1

Let us take a point P(x, y) to be rotated in the anticlockwise direction.

The point P'(x’, y’) is a rotated point, which is the result of anticlockwise rotation transformation performed on point P(x, y) with angle θ angle relative to origin (0, 0). Ø is an angle of a point P from X-axis. According to simple trigonometric principles.

 

X = r cos Ø, y = sin Ø   -> 1

Where r is the length of OP, or the distance of point P from the origin (0, 0). And,

anticlockwise rotation of a point

 

 

x’ = r cos(θ + Ø), y’ = r sin(θ + Ø)    -> 2

In the matrix notation it can be represented as,

[ X’ Y’] = [ X Y ] [ cos θ sin θ ] [ -sin θ cos θ]

P’ = P. Ra

In above equation, Ra is the rotation transformation matrix for rotating a point P in anticlockwise direction with angle θ relative to origin.

Similarly, we can derive the equation to rotate a point in clockwise direction by angle θ about the origin. The rotation figure is

rotation about a point can also be described as rotation about axis

clockwise rotation of a point

 

Here we are rotating point P(x, y) in opposite direction of that we did in the anticlockwise rotation. That

is how in this case angle will be θ.

Rc = [ cos -θ sin -θ ]       [ cos θ -sin θ ] [ -sin -θ cos -θ]       [ sin θ cos θ]

Rc is a rotation transformation matrix to rotate a point in clockwise direction by θ angle relative to the origin.

Download Paper Solutions from Below Link

About admin

Scroll To Top