One of the most common and important tasks in computer graphics is to transform the coordinates (position, orientation, and size) of either objects within the graphical scene or the camera that is viewing the scene. It is also frequently necessary to transform coordinates from one coordinate system to another, (e.g. world coordinates to viewpoint coordinates to screen coordinates.) All of these transformations can be efficiently handled using some simple matrix representations, which we will see can be particularly useful for combining multiple transformations into a single composite transform matrix.
The general procedures for applying translation, rotation, and scaling Parameters to reposition and resize the two dimensional objects.
Translation is a process of changing the position of an object in a straight-line path from one coordinate location to another.We can translate a two dimensional Point by adding translation distances tx and ty, to the original coordinate position (x, y) to move the point to a new position (x’, y’) as shown in the figure (a).
The translation distance pair (tx , ty) is called a translation vector or shift vector.
It is possible to express the translation equations 1 and 2 as a single matrix equation by using column vectors to represent coordinate Positions and the translation vector:
This allows us to write the two dimensional translation equations in the matrix form
P’ = P + T … (3)
A two dimensional rotation is applied to an object by repositioning it along a circular path in the xy plane. To generate a rotation we specify a rotation angle θ and the position of the rotation point about which the object is to be rotated.
Let us consider the rotation of the object about the origin, as shown in the figure (b). Here, r is the constant distance of the point from the origin, angle ∅ is the original angular position of the point from the horizontal, and θ is the rotation angle. Using standard trigonometric equations, we can express the transformed coordinates in terms of angles θ and ∅ as
The original coordinates of the point in polar coordinates are given as
Substituting equations (5) into (4), we get the transformation equations for rotating a point (x, y) through an angle θ about the origin as :
The above equations can be represented in the matrix form as given below
Where R is rotation matrix and it is given as
It is important to note that positive values for the rotation angle define counter clockwise rotations about the rotation point and negative values rotate objects in the clockwise sense.
For negative values of θ i.e., for clockwise rotation, the rotation matrix becomes
c) 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’)
Scaling factor Sx scales object in the x direction and scaling factor Sy scales object in the y direction. The equations (10) can be written in the matrix form as given below:
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 differential scaling.