Unit 4
3D Geometric
Transformation
Asistant Professor Loknath Regmi
1
(CG)
What is 3-Dimension?
• Three-dimensional space is a geometric 3-parameters model
of the physical universe (without considering time) in which all
known matter exists. These three dimensions can be labeled
by a combination of length, breadth, and depth. Any three
directions can be chosen, provided that they do not all lie in
(CG)
Asistant Professor Loknath Regmi
the same plane.
2
What is 3 Dimensional Object?
• An object that has height, width and depth, like any object in
the real world is a 3 dimensional object.
• Types of objects: Geometrical shapes, trees, terrains, clouds,
rocks, glass, hair, furniture, human body, etc.
(CG)
Asistant Professor Loknath Regmi
3
3D Transformations
• Just as 2D-transfromtion can be represented by 3x3 matrices
using homogeneous co-ordinate can be represented by 4x4
matrices, provided we use homogenous co-ordinate
representation of points in 3D space as well.
1. Translation
(CG)
Asistant Professor Loknath Regmi
2. Rotation
3. Scaling
4. Reflection
5. Shear
4
[Link]
• Translation in 3D is similar to translation in the 2D except that
there is one more direction parallel to the z-axis. If, tx, ty, and tz
are used to represent the translation vectors. Then the translation
of the position P(x, y, z) into the point P' (x', y', z') is done by
• x' = x + tx
• y' = y + ty
• z' = z + tz
(CG)
Asistant Professor Loknath Regmi
5
• In matrix notation using homogeneous coordinate this is
performed by the matrix multiplication,
[Link]
i) Rotation About z-axis:
Z-component does not change.
X' = X cosθ – Y sinθ
Y' = X sinθ + Y cosθ
(CG)
Asistant Professor Loknath Regmi
Z' = Z
Matrix representation for rotation around z-axis,
6
[Link]
ii) Rotation About x-axis:
X-component does not change.
Y' = Y cosθ - Z sinθ
Z' = Y sinθ + Z cosθ
X
(CG)
Asistant Professor Loknath Regmi
X' = X
Matrix representation for rotation around X-axis,
Z Y
7
[Link]
iii) Rotation About Y-axis:
Y-component does not change.
Z' = Z cosθ – X sinθ
X' = Z sinθ + X cosθ
(CG)
Asistant Professor Loknath Regmi
Y' = Y
Matrix representation for rotation around Y-axis,
8
[Link]
• General 3D Rotations:
(a) Rotation about an axis parallel to any of the co-axis: When an object is
to be rotated about an axis that is parallel to one of the co-ordinate axis, we
need to perform series of transformation.
i. Translate the object so that the rotation axis coincides with the
parallel co-ordinate axis.
ii. Perform the specified rotation about the axis.
iii. Translate the object so that the rotation axis is moved to its
(CG)
Asistant Professor Loknath Regmi
original position.
9
a) Rotation about an axis parallel to any of the co-axis:
Step 1
• Translate the object so that the rotation axis coincides with
the parallel co-ordinate axis.
(CG)
Asistant Professor Loknath Regmi
10
a) Rotation about an axis parallel to any of the co-axis:
Step 2
• Perform the specified rotation about the axis.
(CG)
Asistant Professor Loknath Regmi
11
a) Rotation about an axis parallel to any of the co-axis:
Step 3
• Translate the object so that the rotation axis is moved to its
original position.
(CG)
Asistant Professor Loknath Regmi
12
a) Rotation about an axis parallel to any of the co-axis:
Step 1:Translate
(CG)
Asistant Professor Loknath Regmi
13
Step 2:Rotation Step 3:Translate to original place
[Link]
• General 3D Rotations:
(b) Rotation about an axis not parallel to any of the co-axis:
i. Translate the object such that rotation axis passes through co-
ordinate origin.
ii. Rotate the axis such that axis of rotation coincides with one of
the co-ordinate axis.
iii. Perform the specific rotation about the ordinate axis.
(CG)
Asistant Professor Loknath Regmi
iv. Apply inverse rotation to bring the rotation axis back to its
original orientation.
v. Apply inverse translation to bring the rotation axis back to its
original position.
14
(b) Rotation about an axis not parallel to any of the co-axis:
(CG)
Asistant Professor Loknath Regmi
15
(b) Rotation about an axis not parallel to any of the co-axis:
(CG)
Asistant Professor Loknath Regmi
16
(b) Rotation about an axis not parallel to any of the co-axis:
(CG)
Asistant Professor Loknath Regmi
17
(b) Rotation about an axis not parallel to any of the co-axis:
(CG)
Asistant Professor Loknath Regmi
18
(b) Rotation about an axis not parallel to any of the co-axis:
(CG)
Asistant Professor Loknath Regmi
19
(b) Rotation about an axis not parallel to any of the co-axis:
(CG)
Asistant Professor Loknath Regmi
20
3. Scaling
Scaling about origin
X’ = X . Sx
Y’ = Y . Sy
Z’ = Z . Sz
(CG)
Asistant Professor Loknath Regmi
21
3. Scaling
• Scaling about an arbitrary point or Fixed point (xf, yf, zf)
(CG)
Asistant Professor Loknath Regmi
22
3. Scaling
• Scaling about an arbitrary point or Fixed point (xf, yf, zf)
(CG)
Asistant Professor Loknath Regmi
23
3. Scaling
• Scaling about an arbitrary point or Fixed point (xf, yf, zf)
Step 1
• Translate the fixed point to the origin
(CG)
Asistant Professor Loknath Regmi
24
3. Scaling
• Scaling about an arbitrary point or Fixed point (xf, yf, zf)
Step 2
• Scale the object relative to the coordinate origin.
(CG)
Asistant Professor Loknath Regmi
25
3. Scaling
• Scaling about an arbitrary point or Fixed point (xf, yf, zf)
Step 3
• Translate the fixed point back to its
original position.
(CG)
Asistant Professor Loknath Regmi
26
C.M.
3. Scaling
Asistant Professor Loknath Regmi
27
(CG)
[Link]
i) Reflection about yz plane
X’ = -X
Y’ = Y
Z’ = Z
(CG)
Asistant Professor Loknath Regmi
28
Y
[Link]
ii) Reflection about XY plane Z’
X’ = X
Y’ = Y
Z’ = -Z
(CG)
Asistant Professor Loknath Regmi
Z X
29
Y
[Link]
iii) Reflection about XZ plane
X’ = X
Y’ = -Y
Z’ = Z
Z X
(CG)
Asistant Professor Loknath Regmi
30
[Link]
• Reflection of an object about a line that is parallel to one of the major
coordinate axes
(CG)
Asistant Professor Loknath Regmi
X
Z [Link] to axis [Link] [Link] to
Y Y Y original position
X X X 31
Z Z Z
[Link]
Shearing transformations can be used to modify object shapes.
Z-axis Shear
• This transformation alters x- and y-coordinate values by an
amount that is proportional to the z value, while leaving the z
coordinate unchanged, i.e,
(CG)
Asistant Professor Loknath Regmi
x' = x + Shx .z
y '= y + Shy .z
z' = z
32
Similarly, we can find X-axis shear and Y-axis shear.
(CG)
Asistant Professor Loknath Regmi
33
Projection
Asistant Professor Loknath Regmi
34
(CG)
What is Projection ?
• Transformation that changes a point in n-dimensional
coordinate system into a point in a coordinate system that has
dimension less than n.
• Converts 3-D viewing co-ordinates to 2-D projection co-
ordinates
(CG)
Asistant Professor Loknath Regmi
• View Plane or Projection Plane: Two dimensional plane in
which 3D objects are projected is called the view plane or
projection plane. Simply it is a display plane on an output
device
35
Types of Projection
1. Parallel Projection
a) Orthographic parallel projection
b) Oblique parallel projection
(CG)
Asistant Professor Loknath Regmi
2. Perspective Projection
36
1 . Parallel Projection
• Coordinate positions are transformed to view plane along
parallel lines (projection lines)
• Preserves relative proportions of objects
• Accurate views of various sides of an object are obtained.
(CG)
Asistant Professor Loknath Regmi
• Doesn’t give realistic representation of the appearance of the
3-D object
• Types
• Orthographic- when the projection is perpendicular to the view
plane. Used to produce Front, Side and Top view of an object
• Oblique – when the projection is not perpendicular to the view
plane
37
1 . Parallel Projection..
Asistant Professor Loknath Regmi
38
(CG)
1 . Parallel Projection..
Asistant Professor Loknath Regmi
39
(CG)
1 . Parallel Projection..
Asistant Professor Loknath Regmi
40
(CG)
1.1. Orthographic Parallel Projection
• When projection is perpendicular to view plane then it is
called orthographic parallel projection
(CG)
Asistant Professor Loknath Regmi
41
1.1. Orthographic Parallel Projection…
Xp=X
Yp=Y
(CG)
Asistant Professor Loknath Regmi
42
Note: Z value is preserved for the depth information needed in depth
culling and visible surface determination procedur
1.2. Oblique Parallel Projection
• Projectors (projection vectors) are not perpendicular to the
projection plane. It preserves 3D nature of an object.
(CG)
Asistant Professor Loknath Regmi
43
1.2. Oblique Parallel Projection…
• Not perpendicular view. (x,y,z) is projected
To position (Xp,Yp) on the view plane.
Y
(Xp,Yp)
Cos θ = Xp / L α(
Xp = L Cos θ (x,y,z)
But exact position is L
Xp = X + L Cos θ
Z θ X
(CG)
Asistant Professor Loknath Regmi
similarly (X,Y)
Sin θ = Yp / L
Yp= Y + L Sin θ
L depend on angle α
Tan α = Z / L
L= Z L1 Where L1 is inverse of tan α
Z
Xp = X +Z L1 Cos θ
Yp= Y + Z L1 Sin θ 44
When α = 0 , i.e. L1= 0 , it is orthographic projection
2. Perspective Projection
• Coordinate positions are transformed to view plane along
lines (projection lines) that converges to a point called
projection reference point (center of projection)
• Produce realistic view
• Does not preserve relative proportions
(CG)
Asistant Professor Loknath Regmi
• Equal sized object appears in different size according as
distance from view plane
45
2. Perspective Projection
Asistant Professor Loknath Regmi
46
(CG)
2. Perspective Projection
Asistant Professor Loknath Regmi
47
(CG)
Perspective View
Asistant Professor Loknath Regmi
48
(CG)
Perspective View
Asistant Professor Loknath Regmi
49
(CG)
Perspective View
Asistant Professor Loknath Regmi
50
(CG)
Y
P(X,Y,Z)
P’(X’,Y’,Z’)
Y
Y’
B(0,Y,Z) O(0,0,0) -Z
Z
Z
(CG)
Asistant Professor Loknath Regmi
X’ C(0,0,-D)
X
A’(X’,0,0)
A(X,0,Z)
X
Here center of Projection is c (0,0,-D) along the direction of Z axis so the reference
point is taken of world coordinate space Wc and the normal vector N is aligned with
the y axis. 51
So now the view plane vp is the xy plane and center of projection is c (0,0,-D) now
from similar triangles ABC and A’OC
D
(CG)
Asistant Professor Loknath Regmi
Triangles ABC and A’OC Triangles APC and A’P’C
(x/x’) = AC/A’C = (Z+D)/D (y/y’) = (AC/AC’) = (Z+D)/D
X’ = (XD)/(Z+D) y’ = (DY)/(Z+D)
And Z’=0 And Z’ =0
now in homogenous coordinates
52
3D-Viewing Pipeline
• The viewing-pipeline in 3 dimensions is almost the same as the 2D-
viewing-pipeline. Only after the definition of the viewing direction
and orientation (i.e., of the camera) an additional projection step is
done, which is the reduction of 3D-data onto a projection plane:
(CG)
Asistant Professor Loknath Regmi
53
Asistant Professor Loknath Regmi
54
(CG)
Finished
Chapter 4
Asistant Professor Loknath Regmi
55
(CG)