2-D Transformation is a basic concept in computer graphics. We’ll cover it in brief as there are many important aspects to it that need to be discussed. So, what do we mean by 2-D transformations?
In the context of computer graphics, it means to alter the orientation, size, and shape of an object with geometric transformation in a
2-D plane. Now, a question arises: What geometric transformations?
Well, we use three basic transformations: Translation, Rotation, and Scaling. Let’s learn about each of them.
1) TRANSLATION: Unlike Rotation, the word ‘translation’ don’t click at first, it’s because we don’t use this word in our day to day lives. But, it’s a very simple and yet a powerful concept. The definition says, repositioning an object along a straight line path from one coordinate location to another. Or in simple words to move an object in 2-D space we can use translation. There is an important point to note here, we are not changing the size or orientation of the object in any way, i.e. we don’t resize or rotate the object, we just move it to some other coordinates.
In order to move an object in 2-D space, we need to add/subtract some value from its x and y coordinates. That distance is known as
‘translational distance‘. One more thing to remember here is that the translational distance pair (tx, ty) is called translation vector or shift vector. New positions (x’, y’) in terms of old coordinate positions (x, y) can be described as:
x’ = x + tx, y’ = y + ty
We can express the translational equation above as a single matrix equation by using column vectors to represent coordinate positions and translational vectors.
P=[x1x2] , P’= [x′1x′2], T= [txty]
Thus, 2-D translation equation in matrix form can be written as P’ =P +T
2) ROTATION: We use this word very frequently in day to day life. In computer graphics, it means the same. To reposition an object along a circular path in the xy plane is called Rotation. There are two things needed for rotation, θ the rotation angle and the position (xr , yr) of the rotation point or pivot point.
Note: Positive values for rotation angle define counter-clockwise direction about the pivot point and vice versa.
With column vector representation, P= R.P
where R= [cosθsinθ−sinθcosθ]
3) SCALING: In simple words, scaling transformation alters the size of an object. It can be achieved by multiplying the coordinate values (x, y) of each vertex by multiplying by scaling factors (sx , sy) .
x’= x.sx, y’= y.sy
With column vector representation, P’ = S.P
where S (scaling matrix)= [sx00sy]
Also, we can do scaling in two ways: 1) Uniform Scaling 2) Differential Scaling
1) Uniform Scaling: When sx and sy are assigned the same values
2) Differential Scaling: Unequal values of sx and sy result in a differential scaling