## Thursday, 6 March 2014

### Computer Graphics Notes - Lab 18 - SCALING

A scaling transformation changes the size of an object. This operation can be carried out for polygons by multiplying the coordinate values (x, y) of each vertex by scaling factors Sx and Sy to produce the transformed coordinates (x', y').

x' = x • Sx and y' = y • Sy

Scaling factor Sx scales object in the x direction and scaling factor Sy scales object in the y direction.

Sx       0
x', y'    =     x y
0      Sy

=         x .   Sx         y .   Sy

=   P . S
Any positive numeric values are valid for scaling factors Sx and Sy. Values less than 1 reduce the size of the objects and values greater than 1 produce an enlarged object. For both Sx and Sy values equal to 1, the size of object does not change. To get uniform scaling it is necessary to assign same value for Sx and Sy. Unequal values for Sx and Sy result in a different scaling.

Example
Scale the polygon with coordinates A(2, 5), B(7, 10) and C(10, 2) by two units in x direction and 2 units in y direction.

HOMOGENOUS COORDINATES
In design and picture formation process, many times we may require to perform translation, rotation and scaling to fit the picture components into their proper positions. To produce a sequence of transformations, we must calculate the transformed coordinates one step at a time. First, coordinates are translated, then these translated coordinates are scaled and finally, the scaled coordinates are rotated. But this sequential transformations process is not efficient. A more efficient approach is to combine sequence of transformations into one transformation so that the final coordinate positions are obtained directly from initial coordinates. This eliminates the calculation of intermediate coordinate values. In order to combine sequence of transformations we have to eliminate the matrix addition with the translation terms. Here, points are specified by three numbers instead of two. This coordinate system is called homogenous coordinate system and it allows us to express all transformation equations as matrix multiplication.

The homogenous coordinate is represented by a triplet (Xw, Yw, W) where

x= Xw/Wandy = Xw/W

For two-dimensional transformations, we have the homogenous parameter W to be any non zero value. But it is convenient to have W = 1. Therefore, each two-dimensional position can be represented with homogenous coordinate as (x, y, 1).

Summing it all up, we can say that the homogenous coordinates allow combined transformation, eliminating the calculation of intermediate coordinate values and thus save required time for transformation and memory required to store the intermediate coordinate values. Let us see the homogenous coordinates for three basic transformations.

To rotate about an arbitrary point, (xp, yp) we have to carry out three steps:
1.     Translate point (xp, yp) to the origin
2.     Rotate it about the origin and
3.     Finally, translate the center of rotation back where it belongs

Therefore, the overall transformation matrix for a counterclockwise rotation by an angle 6 about the point (xp, yp) is given as
Example
Perform a counterclockwise 45° rotation of triangle a (2, 3), B (5, 5), C (4, 3) about point (1, 1).