0% found this document useful (0 votes)
11 views8 pages

Lecture 3

The document discusses rotation transformations in computer graphics, providing example problems that illustrate how to calculate new positions of squares after rotation about the Z-axis. It also covers transformation methods for translating, rotating, reflecting, and scaling objects about arbitrary points and lines, including the necessary transformation matrices for each operation. The document emphasizes the mathematical principles behind these transformations and their applications in graphics applications.

Uploaded by

Sakib Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views8 pages

Lecture 3

The document discusses rotation transformations in computer graphics, providing example problems that illustrate how to calculate new positions of squares after rotation about the Z-axis. It also covers transformation methods for translating, rotating, reflecting, and scaling objects about arbitrary points and lines, including the necessary transformation matrices for each operation. The document emphasizes the mathematical principles behind these transformations and their applications in graphics applications.

Uploaded by

Sakib Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

IPE 411: CAD CAM

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

Figure 1.1: Example for rotation transformation.

1
Solution: The end points of edge are

x1 = 10 × cos 30◦ = 8.66


x2 = 10 × cos 30◦ − 10 × sin 30◦ = 3.66
x3 = 10 × cos 60◦ = 5
y1 = 10 × sin 30◦ = 5
y2 = dy1 + 10 × sin 60◦ = 13.66
y3 = 10 × cos 30◦ = 8.66

The transformation matrix is


   
cos 30 sin 30 0.866 0.5
[TR ] = =
− sin 30 cos 30 −0.5 0.866

or the transformation matrix can also be written as follows


   
cos(−30) − sin(−30) 0.866 0.5
[TR ] = =
sin(−30) cos(−30) −0.5 0.866

Now coordinate points of A, B and C are written in matrix form.


 
8.66
A=
5
 
3.66
B=
13.66
 
−5
C=
8.66
Now new coordinates points of A, B and C are following.
    
∗ 0.866 0.5 8.66 10
A = =
−0.5 0.866 5 0
    
∗ 0.866 0.5 3.66 10
B = =
−0.5 0.866 13.66 10
    
0.866 0.5 −5 0
C∗ = =
−0.5 0.866 8.66 10
We can also consider three coordinate points in same matrix.
 
0 8.66 3.66 −5
0 5 13.66 8.66

Then the new coordinates are


    
0.866 0.5 0 0.866 3.66 −5 0 10 10 0
=
−0.5 0.866 0 5 13.66 8.66 0 0 10 10

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

Figure 1.2: Example of rotation transformation.

Solution: The end points of edge are


x1 = 10 × cos 60◦ = 5
x2 = 10 × cos 30◦ − 10 × cos 30◦ = 3.66
x3 = 10 × cos 30◦ = 8.66
y1 = 10 × sin 60◦ = 8.66
y2 = y1 + 10 × sin 30◦ = 13.66
y3 = 10 × cos 30◦ = 5
Three end coordinate are in same matrix as follows.
 
0 5 −3.66 −8.66
0 8.66 13.66 5
Then the new coordinates are
    
0.866 0.5 0 5 −3.66 8.66 0 0.866 3.66 −5
=
−0.5 0.866 0 8.66 13.66 −5 0 5 13.66 8.66

2 Transforming a Point and Transforming the Axis


Graphics applications often require transformation of objects description form one coordinate
system to another. The process of transformation involves steps like translation and rotation.

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

Translation Matrix to translate Origin to Point P is


 
1 0 0 x
0 1 0 y
T1 = 
0 0

1 z
0 0 0 1

This is also true for rotation, reflection and scaling.

3 Transformation about any Arbitrary Point


3.1 Rotation about an Arbitrary Point
The transformation given earlier for rotation is about the origin of the axes system. It may
sometimes be necessary to get the rotation about any arbitrary base point A as shown in
Fig. 3.1. To derive the necessary transformation matrix, the following complex procedure
would be required.

• Translate the point P to O, the origin of the axes system.

• Rotate the object about origin by the given angle.

• Translate the point back to its original position

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

Figure 3.1: Rotation about an arbitrary point.

5
The required transformation matrix is given by

[T ] = [T3 ] [T2 ] [T1 ]


   
1 0 dX cos θ − sin θ 0 1 0 −dX
[T ] =  0 1 dY   sin θ cos θ 0   0 1 −dY 
0 0 1 0 0 1 0 0 1
 
cos θ − sin θ dX(1 − cos θ) + dY sin θ
[T ] = sin θ cos θ
 −dX sin θ + dY (1 − cos θ) 
0 0 1

3.2 Reflection about an Arbitrary Line


Similar to the above, there are times when the reflection is to be taken about an arbitrary
line as shown in Fig. 3.2.

• 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.

• Mirror the object through 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

Figure 3.2: Reflection about an line point.

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

The required transformation matrix is given by

[T ] = [T5 ] [T4 ] [T3 ] [T2 ] [T1 ]


     
1 0 0 cos θ sin θ 0 1 0 0 cos θ − sin θ 0 1 0 0
[T ] =  0 1 C   − sin θ cos θ 0   0 −1 0   sin θ cos θ 0   0 1 −C 
0 0 1 0 0 1 0 0 1 0 0 1 0 0 1
 
cos 2θ sin 2θ −C sin 2θ
[T ] =  sin 2θ − cos 2θ C(cos 2θ + 1) 
0 0 1

3.3 Scaling about Arbitrary Point


The transformation given earlier for scaling is about the origin of the axes system. However,
sometimes it may be necessary to get the scaling about any arbitrary base point as shown in
Fig. 3.32. To derive the necessary transformation matrix, the following complex procedure
would be required.

1. Translate the point P to O, the origin of the axes system.

2. Rotate the object by the given angle.

3. Translate the point back to its original position.

7
Y

Sy y Sx x
y
P
x

dy

O X
dx

Figure 3.3: Scaling about an arbitrary line.

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

The required transformation matrix is given by

[T ] = [T3 ] [T2 ] [T1 ]


   
1 0 dX Sx 1 0 1 0 −dX
[T ] =  0 1 dY   1 Sy 0   0 1 −dY 
0 0 1 0 0 1 0 0 1
 
Sx 1 dX (1 − Sx ) − dY
[T ] =  1 Sy −dX + dY (1 − Sy ) 
0 0 1

You might also like