W - 2-3D Transformation
W - 2-3D Transformation
Table Of Contents
• Transformation
• Objectives of transformation
• Types of 3D transformation
• 3D Translation & related math
• 3D Rotation & related math
• 3D Scaling & related math
• Uses of 3D translation, rotation, and scaling
2
Introduction
• 3D transformations involve manipulating
points, vectors or polygons in a three-
dimensional space .
3
Transformation
• The term transformation means converting a graphic to
another graphic by applying some rules or algorithms.
4
Objectives of Transformation
• The objective of 3D transformation
in computer graphics is to
manipulate the view of a three-
dimensional object with respect to
its original position by modifying its
physical attributes through various
methods of transformation.
5
Types of 3D Transformation
6
Types of 3D Transformation
• Translation : Move a 3D object from one position to another
7
3D Translation
● When we translate object in the three-dimensional
plan, Then it is called 3D Translation.
● It is the movement of an object from one position to
another position. Translation is done using translation
vectors.
● There are three vectors in 3D instead of two. These
vectors are in x, y, and z directions. Translation in the
x-direction is represented using T x. The translation is
y-direction is represented using T y. The translation in
the z- direction is represented using T z.
8
3D Translation
● If P is a point having co-ordinates in three directions (x,
y, z) is translated, then after translation its coordinates
will be (x1 y1 z1) after translation. Tx Ty Tz are translation
vectors in x, y, and z directions respectively.
● x1=x+ Tx
● y1=y+Ty
● z1=z+ Tz
● Three-dimensional transformations are performed by
transforming each vertex of the object. Following figure
1 shows the translation of point figure 2 shows the
translation of the cube.
9
3D Translation
10
3D Translation
● X1 = x+ Tx
● Y 1= y+Ty
● Z1 = z+ Tz
11
How to draw 3D graph?
12
Example - 1
A point P(3, 4, 5) is translated by a vector T = (2, 2, 2). Find the coordinates of the translated
point P'.
Solution:
To find the translated point P', we need to add the vector T to the coordinates of point P.
P' = P + T
Given point P(3, 4, 5) and vector vector T = (2, 2, 2),we can add corresponding components to
find the translated point:
We know,
x1 = x+ Tx
y1 = y+ Ty
z1 = z+ Tz
13
Example - 1
Now,
x’= x+tx = 3 +2 = 5
y’= y+ty = 4 + 2 = 6
z’= z+tz = 5+ 2 = 7
P' = (5, 6, 7)
14
Example - 2
The vertices A(2, 4, 6) and B (5, 1, 3) translated by a vector T = (3, -1, 2). Find the
coordinates of the vertices of the translated A',B'.
Solution:
To find the coordinates of the translated tA'B', we need to add the vector T to the
coordinates of each vertex.
A' = A + T,
B' = B + T
Given vertices A(2, 4, 6),B(5, 1, 3), and vector T = (3, -1, 2), we can add
corresponding components to find the translated vertices:
15
A' = (2 + 3, 4 - 1, 6 + 2) A' = (5, 3, 8)
Therefore, the coordinates of the vertices of the translated triangle A'B'C' are A'(5, 3, 8), B'
(8, 0, 5).
16
Example - 3
A point has coordinates in the x, y, z direction i.e., (5, 6, 7). The translation is done in the x-
direction by 3 coordinate and y direction. Three coordinates and in the z- direction by two
coordinates. Shift the object. Find coordinates of the new position.
Solution:
Co-ordinate of the point are (5, 6, 7)
Translation vector in x direction Tx = 3
Translation vector in y direction Ty = 3
Translation vector in z direction Tz = 2
We know,
§ x1 = x+ Tx
§ y1 = y+ Ty
§ z1= z+ Tz 17
Example - 3
Now,
x’= x+tx = 5+3 = 8
y’= y+ty = 6+(3) = 9
z’= z+tz = 7+2 = 9
So the new co-ordinate is A’(x’,y’,z’) = (8 ,9 ,9)
18
Example - 4
A point has coordinates in the x, y, z direction i.e., (0, 4, 4). The translation is done in the x-
direction by 4 coordinate and y direction. -4 coordinates and in the z- direction by 0
coordinates. Shift the object. Find coordinates of the new position.
Solution:
Co-ordinate of the point are (x,y,z) = (0, 4, 4)
19
Example - 4
Now,
x’= x+tx = 0+4 = 4
y’= y+ty = 4+(-4) = 0
z’= z+tz = 4+0 = 4
So the new co-ordinate is A’(x’,y’,z’) = (4 ,0 ,4)
20
3D Rotation
● In Computer graphics, 3D Rotation is a process of
rotating an object with respect to an angle in a three
dimensional plane
● Initial coordinates of the object O = (X, Y, Z)
● Rotation angle = θ
● New coordinates of the object O after rotation = (X’, Y’,
Z’)
● In 3 dimensions, there are 3 possible types of rotation-
1. X-axis Rotation
2. Y-axis Rotation
3. Z-axis Rotation
21
3D Rotation
● If We rotate the object according to x-axis
that’s called pitch.
● The rule is
1. X’ = X
2. Y’ = Ycosθ – Zsinθ
3. Z’ = Ysinθ + Zcosθ
For Clockwise,
1. X’ = X
2. Y’ = Ycosθ + Zsinθ
3. Z’ = Ysinθ - Zcosθ
22
0 3D Rotation
3 ● If We rotate the object according to y-axis
that’s called yaw.
● The rule is
1. X’ = Xcosθ + Zsinθ
2. Y’ = Y
3. Z’ = Zcosθ - Xsinθ
For Clockwise,
1. X’ = Xcosθ - Zsinθ
2. Y’ = Y
3. Z’ = Zcosθ + Xsinθ
23
3D Rotation
● If we rotate the object according to z-axis that’s
called roll.
● The rule is
1. X’ = Xcosθ - Ysinθ
2. Y’ = Xsinθ + Ycosθ
3. Z’=Z
For Clockwise,
1. X’ = Xcosθ + Ysinθ
2. Y’ = Xsinθ - Ycosθ
3. Z’=Z
24
3D Rotation
● If we rotate the object according to z-axis that’s
called roll.
● The rule is
1. X’ = Xcosθ - Ysinθ
2. Y’ = Xsinθ + Ycosθ
3. Z’=Z
For Clockwise,
1. X’ = Xcosθ + Ysinθ
2. Y’ = Xsinθ - Ycosθ
3. Z’=Z
25
Example - 1
Given a homogeneous point (1, 2, 3). Apply rotation 90 degree towards X, Y and Z axis
and find out the new coordinate points.
Solution:
Old coordinates = (X, Y, Z) = (1, 2, 3)
Rotation angle = θ = 90º
New coordinate = (X’, Y’, Z’)=?
According to X Axis-
X’=1
Y’= Ycosθ - Zsinθ = 2cos90 - 3sin90 = -3
Z’=Ysinθ + Zcosθ = 2sin90 + 3cos90 = 2
According to Z Axis-
X’ = Xcosθ - Ysinθ = 1cos90 - 2sin90 = -2
Y’ = Xsinθ + Ycosθ = 1sin90 + 2cos90 = 1
Z’ = Z = 3
New co-ordinate (X’ Y’ Z’) = (-2, 1, 3).
27
Example - 2
A box has 7 points. Points are A(0,4,0) , B(0,4,4) , C(4,4,0) , D(4,4,4) , E(4,0,0) , F(0,0,4) ,
G(4,0,4). Now we have to rotate the box around 45 degree according to Y-axis.
Solution:
Here are the rules-
X’ = Xcosθ + Zsinθ
Y’ = Y
Z’ = Zcosθ - Xsinθ
Now for A(0,4,0)-
X’ = Xcosθ + Zsinθ= 0cos45+ 0sin45 = 0 + 0 = 0
Y’= Y
Z’ = Zcosθ - Xsinθ= 0cos45 – 0sin45 = 0
So A’ is (0,4,0)
28
Example - 2
Now for B(0,4,4)-
X’ = Xcosθ + Zsinθ= 0cos45+ 4sin45 = 0 + 4*1/√2 = 2√2
Y’ = Y = 4
Z’ = Zcosθ - Xsinθ = 4cos45-0sin45 = 4*1/√2-0 = 2√2
So B’ is(2√2,4,2√2)
29
Example - 2
Now for D(4,4,4)-
X’ = Xcosθ + Zsinθ = 4cos45 + 4sin45 = 4*1/√2+4*1/√2 = 4√2
Y’= Y = 4
Z’ = Zcosθ - Xsinθ= 4cos45-4sin45 = 4*1/√2-4*1/√2 = 0
So, D’ is (2√2,4,0)
30
Example - 2
Now for F(0,0,4)-
X’ = Xcosθ + Zsinθ= 0cos45 + 4sin45 =0+ 4*1/√2 = 2√2
Y’= Y = 0
Z’ = Zcosθ - Xsinθ = 4cos45-0sin45 = 4*1/√2 - 0 = 2√2
So, F’ is (2√2,0,2√2)
31
Example - 2
Here the new points we’ve got are-
A’(0,4,0)
B’(0,4,0)
C’(0,4,0)
D’(0,4,0)
E’(0,4,0)
F’(0,4,0)
G’(0,4,0)
32
3D Scaling
• In computer graphics, scaling is a process of modifying or altering the size of objects. The
size can be increased or decreased.
33
3D Scaling
• The scaling three factors are required Sx Sy and Sz.
34
Consider a point object O has to be scaled in a 3D plane.
Let, Initial coordinates of the object O = (X old, Yold, Zold)
New coordinates of the object O after scaling = (X new, Ynew , Znew )
35
Example-1
Consider the above problem where a cube” OABCDEFG” is given O(0, 0, 0, ), A(0, 4, 0),
B(0, 4, 4), C(4, 4, 0), D(4, 4, 4), E(4, 0, 0), F(0, 0, 4), G (4, 0, 4) and the scaling parameters
are 2 along with x-axis, 3 along with y-axis and 2 along with z-axis. Perform Scaling
operation over the cube.
Fig: 1
36
Example-1
Solution :
Now, applying the Matrix Scaling transformation condition we get –
37
Example-1
After performing the Scaling Transformation successfully the Fig.1 will look like as below
Fig.2 –
Fig: 2
38
Example-2
A 3D object that have coordinates points P(1, 4, 4), Q(4, 4, 6), R(4, 1, 2), T(1, 1, 1) and the
scaling parameters are 3 along with x-axis, 4 along with y-axis and 4 along with z-axis.
Apply scaling to find the new coordinates of the object?
Solution :
We have,
The initial coordinates of object = P (1, 4, 4), Q (4, 4, 6), R (4, 1, 2), S (1, 1, 1)
Given that, Scaling factors:
(Sx) = 3,
(Sy) = 4,
(Sz) = 4
Let the new coordinates after scaling = (x1, y1, z1)
39
Example-2
For coordinate P- For coordinate R-
x1 = x0 x Sx = 1 x 3 = 3 x1 = x0 x Sx = 4 x 3 = 12
y1 = y0 x Sy = 4 x 4 = 16 y1 = y0 x Sy = 1 x 4 = 4
z1 = z0 x Sz = 4 x 4 = 16 z1 = z0 x Sz = 2 x 4 = 8
The new coordinates = (3, 16, 16) The new coordinates = (12, 4, 8)
Thus, the new coordinates after scaling = P (3, 16, 16), Q (12, 16, 24), R (12, 4, 8), S (3, 4, 4).
40
Uses of 3D Translation, Rotation,
Scaling
● 3D translation, rotation, and scaling are three of the
most fundamental operations in 3D computer
graphics.
● Manipulate the position, orientation, and size of 3D
objects in a scene.
● Moving objects around the scene.
● Rotating objects around their axes.
● Scaling objects up or down.
● Creating different views of an object.
41