Home »
Computer Graphics
Types of Transformations (Reflection and Shearing) in Computer Graphics
Computer Graphics | Reflection and Shearing: In this tutorial, we are going to learn about the Reflection and Shearing which are types of Transformation in computer graphics, the ways in which an image is transformed in each of these methods.
By Monika Sharma Last updated : April 05, 2024
Reflection
The reflection is just like the mirror image of the original image. The mirror image can be either about the x-axis or the y-axis. In the reflection process, the size of the object does not change. We can also say that the reflection is a kind of rotation where the angle of rotation is 180 degrees, while the reflected object is always formed on the other side of the mirror and the size of the reflected image is the same as the size of the original image.
We can see reflection of object in these four ways:
- Reflection along X-axis
- Reflection along Y-axis
- Reflection along the line(x=y)
- Reflection perpendicular to XY-axis
Now let us understand reflection with the help of an example,
Reflection Example
Problem Statement: Given a triangle with coordinate points A (3, 4), B (6, 4), C (5, 6). Apply the reflection on the X-axis and obtain the new coordinates of the object.
Solution:
Given -
- Old corner coordinates of the triangle = A (3, 4), B (6, 4), C (5, 6)
- Reflection has to be taken on the X-axis
For the co-ordinates A (3, 4)
Let the new co-ordinates of corner A after reflection be = (Xnew, Ynew).
When we apply the reflection equations, we get:
Xnew = Xold = 3
Ynew = -Yold = -4
Thus, the new co-ordinates of corner A after reflection is = (3, -4).
For the co-ordinates B (6, 4)
Let the new co-ordinates of corner B after reflection be = (Xnew, Ynew).
When we apply the reflection equations, we get-
Xnew = Xold = 6
Ynew = -Yold = -4
Thus, the new co-ordinates of corner B after reflection is = (6, -4).
For the co-ordinates C (5, 6)
Let the new coordinates of corner C after reflection be = (Xnew, Ynew).
When we apply the reflection equations, we get-
Xnew = Xold = 5
Ynew = -Yold = -6
Thus, the new co-ordinates of corner C after reflection is = (5, -6).
Thus, the new co-ordinates of the triangle after reflection will be = A (3, -4), B (6, -4), C (5, -6).
Shearing
Shearing is the transformation of an object which changes the shape of the object. The shearing can be in one direction or two directions. It is an ideal technique to change the shape of an existing figure. The sliding of layers of the object occurs while doing the same. Shearing can be done in three ways,
- Shearing in the X-direction
- Shearing in the Y-direction
- Shearing in the X-Y direction
Shearing in X axis can be done using this equation,
- Xnew = Xold + Shx x Yold
- Ynew = Yold
Shearing in Y axis can be done using this equation,
- Xnew = Xold
- Ynew = Yold + Shy x Xold
Now let us understand shearing more clearly with the help of an example,
Shearing Example
Problem Statement: Given a triangle with points A (1, 1), B (0, 0) and C (1, 0). You need to apply shear parameter 2 on the X-axis and 2 on Y-axis and find out the new coordinates of the object.
Solution:
Given-
- Old corner co-ordinates of the triangle = A (1, 1), B(0, 0), C(1, 0)
- Shearing parameter towards X-direction (Shx) = 2, Y direction (Shy) = 2
Shearing in X Axis
For the co-ordinates A (1, 1):
Let the new co-ordinates of corner A after shearing be = (Xnew, Ynew).
When we apply the shearing equations, we get-
- Xnew= Xold + Shx x Yold = 1 + 2 x 1 = 3
- Ynew= Yold = 1
Thus, the new co-ordinates of corner A after shearing is = (3, 1).
For the co-ordinates B (0, 0):
Let the new co-ordinates of corner B after shearing be = (Xnew, Ynew).
When we apply the shearing equations, we get-
- Xnew= Xold + Shx x Yold = 0 + 2 x 0 = 0
- Ynew= Yold = 0
Thus, the new co-ordinates of corner B after shearing is = (0, 0).
For the co-ordinates C (1, 0)
Let the new co-ordinates of corner C after shearing be = (Xnew, Ynew).
When we apply the shearing equations, we get-
- Xnew= Xold + Shx x Yold = 1 + 2 x 0 = 1
- Ynew= Yold = 0
Thus, the new co-ordinates of corner C after shearing is = (1, 0).
Thus, the new co-ordinates of the after shearing in X axis = A (3, 1), B (0, 0), C (1, 0).
Shearing in Y Axis
For the co-ordinates A (1, 1)
Let the new coordinates of corner A after shearing be = (Xnew, Ynew).
When we apply the shearing equations, we get-
- Xnew= Xold = 1
- Ynew= Yold + Shy x Xold = 1 + 2 x 1 = 3
Thus, the new co-ordinates of corner A after shearing is = (1, 3).
For the co-ordinates B (0, 0)
Let the new co-ordinates of corner B after shearing be = (Xnew, Ynew).
When we apply the shearing equations, we get-
- Xnew= Xold = 0
- Ynew= Yold + Shy x Xold = 0 + 2 x 0 = 0
Thus, the new co-ordinates of corner B after shearing is = (0, 0).
For the co-ordinates C (1, 0)
Let the new co-ordinates of corner C after shearing be = (Xnew, Ynew).
When we apply the shearing equations, we get-
- Xnew= Xold = 1
- Ynew= Yold + Shy x Xold = 0 + 2 x 1 = 2
Thus, new co-ordinates of corner C after shearing is = (1, 2).
Thus, the new co-ordinates of the triangle after shearing in Y axis is = A (1, 3), B (0, 0), C (1, 2).