What is transformation? In many cases a complex picture can always be treated as a combination of straight line, circles, ellipse etc., and if we are able to generate these basic figures, we can also generate combinations of them. Once we have drawn these pictures, the need arises to transform these pictures.
We are not essentially modifying the pictures, but a picture in the center of the screen needs to be shifted to the top left hand corner, say, or a picture needs to be increased to twice it's size or a picture is to be turned through 90^{0 }. In all these cases, it is possible to view the new picture as really a new one and use algorithms to draw them, but a better method is, given their present form, try to get their new counter parts by operating on the existing data. This concept is called transformation.
The three basic transformations are
(i) Translation
(ii) rotation and
(iii) Scaling.
Translation refers to the shifting of a point to some other place, whose distance with regard to the present point is known. Rotation as the name suggests is to rotate a point about an axis. The axis can be any of the coordinates or simply any other specified line also. Scaling is the concept of increasing (or decreasing) the size of a picture. (in one or in either directions. When it is done in both directions, the increase or decrease in both directions need not be same) To change the size of the picture, we increase or decrease the distance between the end points of the picture and also change the intermediate points are per requirements.
Translation:
Consider a point P(x_{1 }, y_{1 }) to be translated to another point Q(x_{2 }, y_{2 }). If we know the point value (x_{2}_{,} y_{2}) we can directly shift to Q by displaying the pixel (x_{2}, y_{2}). On the other hand, suppose we only know that we want to shift by a distance of Tx along x axis and Ty along Y axis. Then obviously the coordinates can be derived by x_{2} =x_{1} +Tx and Y_{2 } = y_{1 }+ T_{y }.
Suppose we want to shift a triangle with coordinates at A(20,10), B(30,100) and C(40,70). The shifting to be done by 20 units along x axis and 10 units along y axis. Then the new triangle will be at A^{1 }(20+20, 10+10) B^{1 } (30+20, 10+10) C^{1 }(40+20, 70+10) In the matrix form [x_{2 } y_{2 } 1] = [x_{1 } y_{1 } 1]
Rotation
Suppose we want to rotate a point (x1 y1) clockwise through an angle? about the origin of the coordinate system. Then mathematically we can show that
x2 = x1cos ? + y1sin? and
y2 = x1sin? - y1cos?
These equations become applicable only if the rotation is about the origin.
In the matrix for [x_{2} y_{2} 1] = [x_{1} y_{1} 1]
Scaling : Suppose we want the point (x_{1} y_{1}) to be scaled by a factor sx and by a factor sy along y direction.
Then the new coordinates become : x_{2} = x_{1} * sx and y_{2} = y_{1} * sy
(Note that scaling a point physically means shifting a point away. It does not magnify
the point. But when a picture is scaled, each of the points are scaled differently and hence the dimensions of the picture changes.)
Dinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.
Related Articles
Basic Courses
Advance Courses