Lecture 3
Lecture 3
Lecture Sheet-3
Imran Ahmed
Asst. Prof., Department of IPE
MIST, Dhaka, Bangladesh
Computer Graphics
1 Example Problem of Rotation Transformation
Example Problem-1: A square (Fig 1.1) with an edge length of 10 units is located in the
origin with one of the edges at an angle of 30◦ with the +X-axis. Calculate the new position
of the square if it is rotated about the Z-axis by an angle of 30◦ in the clockwise direction.
B(x3,y3)
C(x4,y4)
A(x2,y2) 10
o
30
X
-X O
-Y
1
Solution: The end points of edge are
2
Example Problem-2: A square (Fig 1.2) with an edge length of 10 units is located in the
origin with one of the edges at an angle of 60◦ with the +X-axis. Calculate the new position
of the square if it is rotated about the Z-axis by an angle of 30◦ in the clockwise direction.
Y
B(x3,y3)
A(x2,y2)
C(x4,y4) 10
o
60
X
-X O
-Y
3
This transformation can be done in two different ways either by transforming a point of the
object or by transforming the axis to a point on object. Both of these methods are literally
as well as mathematically opposite to each other. For example the matrix for translating
point P(x,y,z) to origin the matrix would be exactly the mathematical inverse of the matrix
for translating Origin to point P [? ].
Translation Matrix to translate point P to Origin is
1 0 0 −x
0 1 0 −y
T1 =
0 0 1 −z
0 0 0 1
Note that rotation point is transferred to the origin, because rotation transfer
matrix Tr is determined based on the origin. So whenever we want apply any
type of transformation of any object about any arbitrary point or arbitrary axis
then we need to shift arbitrary point to origin and arbitrary axis to any coordi-
nate axis which is parallel to that arbitrary axis. The same rule is applicable to
scaling and reflection transformation.
4
The transformation matrices for the above operations in the given sequence are
1 0 −dX
[T1 ] = 0 1 −dY
0 0 1
cos θ − sin θ 0
[T2 ] = sin θ cos θ 0
0 0 1
1 0 dX
[T3 ] = 0 1 dY
0 0 1
Y
P*
P
r
r
dx A
dy
O
-X X
-Y
5
The required transformation matrix is given by
• Translate the mirror line along the Y-axis such that the line passes through the origin,
O.
• Rotate the mirror line such that it coincides with the X-axis.
• Rotate the mirror line back to the original angle with the X-axis.
• Translate the mirror line along the Y-axis back to the original position.
P*
C
θ
-X X
-Y
6
The transformation matrices for the above operations in the given sequence are
1 0 0
[T1 ] = 0 1 −C
0 0 1
cos θ sin θ 0
[T2 ] = − sin θ cos θ 0
0 0 1
1 0 0
[T3 ] = 0 −1 0
0 0 1
cos θ − sin θ 0
[T4 ] = sin θ cos θ 0
0 0 1
1 0 0
[T5 ] = 0 1 C
0 0 1
7
Y
Sy y Sx x
y
P
x
dy
O X
dx
The transformation matrices for the above operations in the given sequence are
1 0 −dX
[T1 ] = 0 1 −dY
0 0 1
Sx 1 0
[T2 ] = 1 Sy 0
0 0 1
1 0 dX
[T3 ] = 0 1 dY
0 0 1