Home »
Computer Graphics
Types of Transformations in Computer Graphics
Computer Graphics | Types of Transformations: In this tutorial, we will be explaining Translation, Rotation, Scaling, Reflection and Shearing, etc.
By Monika Sharma Last updated : April 05, 2024
What is Transformation?
Transformation refers to the mathematical operations or rules that are applied on a graphical image consisting of the number of lines, circles, and ellipses to change its size, shape, or orientation. It can also reposition the image on the screen.
Transformations play a very crucial role in computer graphics.
Types of Transformations
There are various types of transformations in computer graphics through which an image can be processed, edited ad altered. Some basic and most commonly used types of these transformations are:
- Translation
- Rotation
- Scaling
- Reflection
- Shearing
1. Translation
Translation refers to a technique in which a point is shift from one place to another, whose distance is known.
Consider a point A(x1, y1) be shifted to another point B (x2, y2). Now we only know the shifting distance tx along x-axis and ty along y-axis.
Now, the new coordinates (x2, y2) can be calculated as:
x2 = x1 + tx
y2 = y1 + ty
For example:
Suppose we want to shift a point with coordinates at A(30,100) and distance along x-axis is 10 units and 20 units along y-axis.
Using translation:
Here tx = 10 ;
and ty = 20
New coordinates A’ (x2, y2):
x2 = 30 + 10 = 130
y2 = 100 + 20 = 120
The point will be shifted to A’ (130, 120 ).
2. Rotation
Rotation refers to mathematical operation in which the graphical object is rotated about an angle (θ) to the axis.
Rotation is of two types: anti-clockwise and clockwise rotation.
Suppose we want to rotate a point with coordinates A (x1, y1) clockwise through an angle θ about the origin
Then the new coordinates (X', y'):
x'= x.cosθ - y.sinθ
y'= x.sinθ + ycosθ
3. Scaling
Scaling refers to a mathematical rule applied to change the size of the image.
If the value of scaling factors is negative, the size is decreased and when the value is positive, the size of the image is increased.
Suppose the point with coordinates A (x1, y1) is to be scaled by a factor sx along the x-axis and sy along the y-axis.
Hence the new coordinates after scaling will be:
x2 = x1 x sx
y2 = y1 x sy
Translation, rotation and scaling are termed as basic translations.
4. Reflection
Reflection refers to the mirror image of the original graphical object. It is an 180o rotation operation.
Reflection can be done about following ways:
- x-axis
- y-axis
- the origin and
- A plane perpendicular to the origin
5. Shearing
Shearing is a transformation in which the shape of the object is slanted about the axis.
In y-shearing:
The new-coordinates will be:
x' = x
y' = y + sy x
In x-shearing:
The new-coordinates will be:
x' = x + sx y
y' = y