Lecture - 5 Geometrical Transformations
Lecture - 5 Geometrical Transformations
DURAME CAMPUS
COLLEGE OF ENGINEERING AND TECHNOLOGY
SCHOOL OF COMPUTING AND INFORMATICS
DEPARTMENT OF COMPUTER SCIENCE
LECTURE_5:- GEOMETRICAL TRANSFORMATIONS
Compiled by Selamu S.
Geometric Transformation-2D
Transformation means changing some graphics into something else by applying rules.
Transformation is changing of an objects after creation, in terms of position or size.
We can have various types of transformations such as translation, scaling up or down, rotation,
reflection, shearing, etc.
When a transformation takes place on a 2D plane, it is called 2D transformation.
Transformations play an important role in computer graphics to reposition the graphics on the
screen and change their size or orientation.
In many applications, changes in orientations, size, and shape are accomplished with geometric
transformations that alter the coordinate descriptions of objects.
𝐏 ′= 𝐏 + 𝐓
Example 1: Translate the triangle with the vertex of A(2,2), B(10,2) and C(5,5) and the
translating factor of the triangle is (5,6).
Ax′ = x + tx Ay ′ = x + ty Bx′ = x + tx By ′ = x + ty C x′ = x + tx C y ′ = x + ty
= 2+5 = 2+6 = 10 + 5 = 2+6 = 5+5 = 5+6
= 7 = 8 = 15 = 8 = 10 = 8
(7, 8) (15, 8) (10, 11)
11/09/2024 CHAPTER 5: GEOMETRICAL TRANSFORMATIONS 11
2D Translation (Cont…;)
EXERCISE 1
1) Translate the square with the vertex of (0,0), (2,0), (0,2) (2,2) and the translating factor of
the square is (2,3).
2) Translate the rectangle (2,2), (2,8), (10,8), (10,2) with 2 units along x-axis and 3 units along
y-axis.
3) 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.
4) Translate a polygon with coordinates A (2, 5), B (7, 10) and C (10, 2) by 3 units in x-
direction and 4 units in y-direction.
♣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.
♣Scaling a coordinate means multiplying each of its components by a scalar
♣Uniform scaling:- means this scalar is the same for all components.
♣Non-uniform scaling:- different scalars per component.
♣ 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 is scaled differently and hence the dimension of
the picture changes.
♣ Scaling means to change the size of the picture.
♣ If (P) is the initial point and after scaling the point is (PO, then
𝐏 ′= 𝐒 ∗ 𝐏
11/09/2024 CHAPTER 5: GEOMETRICAL TRANSFORMATIONS 18
2D Scaling (Cont…;)
Example 1: Consider a triangle formed by the points A (5,5), B(10,10) and C (10,5). Suppose we
scale it by a factor of 3 along x-axis and 2 along y-axis.
Soln: First Case: (5,5) Second Case: (10,10) Third Case: (5,5)
X' = Sx* X Y' = Sy* Y' X' = Sx* X Y' = Sy* Y' X' = Sx* X Y' = Sy* Y'
=5*3 =5*2 = 10 * 3 = 10 * 2 = 10 * 3 =5*2
= 15 = 10 = 30 = 20 = 30 = 10
(15, 10) (30, 20) (30, 10)
EXERCISE 3
1) Scale a triangle with respect to the origin, with vertices at original coordinates (10,20), (10,10),
(20,10) by sx=2, sy=1.5
2) Scale a triangle with vertices at original coordinates (10,25), (5,10), (20,10) by sx=1.5, sy=2,
with respect to the origin. Roughly plot the original and resultant triangles.
11/09/2024 CHAPTER 5: GEOMETRICAL TRANSFORMATIONS 19
Matrix Representation
♠ Represent 2D transformation by a matrix
a b
c d
♠ Multiply matrix by column vector
apply transformation to point
x' s x 0 x
y ' 0
s y y Scaling
[][ ][ ]
𝑥′ 𝑠𝑥 0 0 𝑥 =>
𝑦′ = 0 𝑠𝑦 0 𝑦
1 0 0 1 1
1 0 0 1 1
x s x 0 0 x
y 0 sy 0 y
Scaling
1 0 0 1 1
x ' x
y ' y
11/09/2024 CHAPTER 5: GEOMETRICAL TRANSFORMATIONS 37
Reflection about X-axis (Cont…;)
♣ So the transformation matrix for reflection about x-axis or y=0 axis is:
1 0
Tm y 0
0 1
♣ And the transformation matrix is represented as:
x ' 1 0 x
y '
0 1 y
1 0
Tm x0
0 1
♣ Where
0 1
1 0 is the transformation matrix Tm y x
11/09/2024 CHAPTER 5: GEOMETRICAL TRANSFORMATIONS 40
Reflection about the Straight line y= -x
♣ Considering the experimental point (x, y), we find that P and its image P’ both being the 4 th
quadrant, x, and x’ are (+ve) where as y, and y’ are (-ve).
♣ So considering this fact we should write,
x ' y
y ' x
♣ This can be represented by:
x ' 0 1 x
y ' 1 0 y
0 1 Tm y x
Where is the transformation matrix
1 0
11/09/2024
CHAPTER 5: GEOMETRICAL TRANSFORMATIONS 41
Shear
♣ A transformation that slants the shape of an object is called the shear transformation.
♣ It is similar to sliding the layers in one direction to change shape of the object.
♣ Shearing an object consists of linearly deforming it along either x-axis or y-axis or both.
♣ There are two shear transformations X-Shear and Y-Shear.
♣ One shifts x coordinates values and other shifts y coordinate values.
♣ However; in both the cases only one coordinate changes its coordinates and other preserves
its values.
♣ Shearing is also termed as Skewing.
x ' 1 shx x
y ' 0 1 y
x ' 1 0 x
y ' sh
1 y
y
11/09/2024 CHAPTER 5: GEOMETRICAL TRANSFORMATIONS 44
Shear (Cont…;)
Example 1: a triangle with A(2,2), B(0,0) and C(2,0). Apply shearing factor of 2 on x-axis and 2
on y-axis. Find out the new coordinates of the triangle.
x ' x shx * y
Solution: X-Shear Coordinates
y ' y
A(2,2), B(0,0) C(2,0) shx=2 shy=2
X-shear A: x ' x sh * y 2 2* 2 6
x X-shear C:
y ' y 2 x ' x shx * y 2 2*0 2
(6, 2) y ' y 0
X-shear B: (2, 0)
x ' x shx * y 0 2*0 0
y ' y 0
(0, 0)
11/09/2024 CHAPTER 5: GEOMETRICAL TRANSFORMATIONS 45
Shear (Cont…;)
Solution: Y-Shear Coordinates x ' x
A(2,2), B(0,0) C(2,0) shx=2 shy=2 y ' y shy * x
Y-shear A: x ' 2
y ' 2 2 * 2 6
(2, 6)
Y-shear C: x ' 2
Y-shear B: x ' 0 y ' 0 2 * 0 0
y ' 0 2 * 0 0 (2, 0)
(0, 0)
x 1 0 0 tx x 1 0 0 3 5 8
y 0 1 0 t y y 0 6 9
1 0 3
z ' 0 0 1 tz z 0 0 1 2 7 9
1 0 0 0 1 1 0 0 0 1 1 1
11/09/2024 CHAPTER 5: GEOMETRICAL TRANSFORMATIONS 49
3D Scaling
♣ Scaling in 3D is also an extension of scaling in 2D.
♣ Scaing is the transformation which will change the object size, based on the scaling factors s x,
x 1 0 0 0 x
y 0 cos sin
0 y
z ' 0 sin cos 0 z
1 0 0 0 1 1