Transformation Problems
Transformation Problems
•Old corner coordinates of the square = A (0, 3), B(3, 3), C(3, 0), D(0, 0)
•Scaling factor along X axis = 2
•Scaling factor along Y axis = 3
For Coordinates A(0, 3)
In Computer graphics,
2D Rotation is a process of rotating an object with respect to an angle in a two
dimensional plane.
Given a line segment with starting point as (0, 0) and ending point as (4, 4). Apply 30-
degree rotation anticlockwise direction on the line segment and find out the new
coordinates of the line.
Solution-
We rotate a straight line by its end points with the same angle. Then, we re-draw a line between the
new end points.
Given-
•Old ending coordinates of the line = (Xold, Yold) = (4, 4)
•Rotation angle = θ = 30º
Let new ending coordinates of the line after rotation = (Xnew, Ynew).
Applying the rotation equations, we have-
Xnew = Xold cosθ – Yold sinθ
= 4.cos30º – 4.sin30º = 4 x (√3 / 2) – 4 x (1 / 2) = 2√3 – 2= 2(√3 – 1)= 2(1.73 – 1)= 1.46
Ynew = Xold x sinθ + Yold x cosθ
= 4 x sin30º + 4 x cos30º = 4 x (1 / 2) + 4 x (√3 / 2) = 2 + 2√3 = 2(1 + √3) = 2(1 + 1.73) = 5.46
Thus, New ending coordinates of the line after rotation = (1.46, 5.46).
Alternate
Method
Thus, New ending coordinates of the line after rotation = (1.46, 5.46).
Given a triangle with corner coordinates (0, 0), (1, 0) and (1, 1). Rotate the triangle by 90-degree
anticlockwise direction and find out the new coordinates.
Solution-
We rotate a polygon by rotating each vertex of it with the same rotation angle.
Given-
•Old corner coordinates of the triangle = A (0, 0), B(1, 0), C(1, 1)
•Rotation angle = θ = 90º
For Coordinates A(0, 0)
Let the new coordinates of corner A after rotation = (Xnew, Ynew).
Applying the rotation equations, we have-
Xnew= Xold .cosθ – Yold .sinθ = 0 .cos90º – 0 .sin90º = 0
Ynew = Xold .sinθ + Yold .cosθ = 0 .sin90º + 0 .cos90º = 0 Thus, New coordinates of corner
A after rotation = (0, 0).
For Coordinates B(1, 0)
Let the new coordinates of corner B after rotation = (Xnew, Ynew).
Xnew = Xold .cosθ – Yold .sinθ = 1 .cos90º – 0 .sin90º = 0
Ynew = Xold .sinθ + Yold .cosθ = 1 .sin90º + 0 .cos90º = 1 + 0 = 1
Thus, New coordinates of corner B after rotation = (0, 1).
For Coordinates C(1, 1)
Let the new coordinates of corner C after rotation = (Xnew, Ynew).
Xnew = Xold x cosθ – Yold x sinθ = 1 x cos90º – 1 x sin90º = 0 – 1 = -1
Ynew = Xold x sinθ + Yold x cosθ = 1 x sin90º + 1 x cos90º = 1 + 0 = 1
[ ] [ ]
𝑇1= 0
0
1
0
− 𝑡𝑦
1 [
𝑇 2 = 𝑠𝑖𝑛 𝜃
0
𝑐𝑜𝑠 𝜃
0
0
1 ] 𝑇3= 0
0
1
0
𝑡𝑦
1
0.866
−0.5 20.51 25
T.B ¿ 0.5
0 [ 0.866
0
− 2.54
1 ][ ]
35
1