Computer Graphics [Link] Cs.
IT 3rd Sem | Prithivi Narayan Campus Dev Timilsina
Three-Dimensional Geometric Transformations
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 labelled by a combination of length, breadth, and depth. Any three directions can be
chosen, provided that they do not all lie in the same plane.
An object that has height, width and depth, like any object in the real world is a 3-
dimensional object.
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 --- Moving an object – tx,ty,tz
2. Rotation -- Rotating with some degree x,y,z rotation
3. Scaling – Change size/ Shape Sx,Sy, Sz
4. Reflection – Rotation with 1800 xy,yz,zx plane
5. Shear --- Tilting the object x,y,x - shear
❖ Translation
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
1|Page timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
In matrix notation using homogeneous coordinate this is performed by the matrix
multiplication.
❖ Rotation
For 3D rotation we need to pick an axis to rotate about. The most common choices are
the X-axis, the Y-axis, and the Z-axis.
Coordinate-Axes Rotations
2|Page timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
Z-Axis Rotation
Two-dimension rotation equations can be easily converting into 3D Z-axis rotation
equations. Rotation about z axis we leave z coordinate unchanged.
X’ = x cos θ − y sinθ
Y’ = x sinθ + y cos θ
Z’ = z
Where Parameter θ specify rotation angle.
Matrix equation is written as:
P’ = Rz(θ) ∙ P
X-Axis Rotation
Transformation equation for x-axis is obtain from equation of z-axis rotation by replacing
cyclically as shown here
x→y→z→x
Rotation about x axis we leave x coordinate
unchanged.
y’ = y cos θ − zsin θ
z’ = y sin θ + z cos θ
x’ = x
3|Page timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
Where Parameter θ specify rotation angle.
Matrix equation is written as:
P′ = Rx(θ) ∙ P
Y-Axis Rotation
Transformation equation for y-axis is obtain from equation of x-axis
rotation by replacing cyclically as shown here
y→ z → x→ y
Rotation about y axis we leave y coordinate unchanged.
z' = z cos θ − x sinθ
x’ = z sin θ + x cos θ
y’ = y
Where Parameter θ specify rotation angle.
Matrix equation is written as:
P′ = Ry(θ) ∙ P
4|Page timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
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 axes, 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 original position.
This can be represented in equation form as:
P′ = T−1∙ R(θ) ∙ T ∙ P
b. Rotation about an axis not parallel to any arbitrary direction
5|Page timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
When object is to be rotated about an axis that is not parallel to one of the coordinate
axes, we need rotations to align the axis with a selected coordinate axis and to bring the
axis back to its original orientation. Five steps require to complete such rotation.
I. Translate the object so that the rotation axis passes through the coordinate origin.
II. Rotate the object so that the axis of rotation coincides with one of the coordinate
axes.
III. Perform the specified rotation about that coordinate axis.
IV. Apply inverse rotations to bring the rotation axis back to its original orientation.
V. Translate the object so that the rotation axis is moved to its original position.
We can transform rotation axis onto any of the three coordinate axes. The Z-axis is a
reasonable choice.
❖ Scaling
➢ It is used to resize the object in 3D space.
➢ We can apply uniform as well as non-uniform scaling by selecting proper scaling
factor.
➢ Scaling in 3D is similar to scaling in 2D. Only one extra coordinate need to consider
into it.
Coordinate Axes Scaling
6|Page timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
Simple coordinate axis scaling can be performed as below.
P′ = S ∙ P
Fixed Point Scaling
Fixed point scaling is used when we require scaling of object but particular point must
be at its original position. Fixed point
scaling matrix can be obtained in three
step procedures.
1. Translate the fixed point to the origin.
2. Scale the object relative to the
coordinate origin using coordinate axes
scaling.
3. Translate the fixed point back to its
original position.
7|Page timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
❖ Reflections
Reflection means mirror image produced when mirror is placed at require position.
When mirror is placed in XY-plane we obtain coordinates of image by just changing
the sign of z-coordinate. There are three planes xy,yz and zx. It is also similar with 2D
reflection only z- coordinate is added.
8|Page timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
• Transformation matrix for reflection about XY-plane is given below.
X’ = X
Y’ = Y
Z’ = -Z
• Similarly, Transformation matrix for reflection about YZ-plane is.
X’ = -X
Y’ = Y
Z’ = Z
• Similarly, Transformation matrix for reflection about XZ-plane is.
X’ = X
Y’ = -Y
Z’ = Z
9|Page timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
Reflection of an object about a line that is parallel to one of the major coordinate axes
❖ Shear
Shearing transformation can be used to modify object shapes.
They are also useful in 3D viewing for obtaining general projection transformations.
Z-axis Shear
Here we use shear parameter ‘a’ and ‘b’. This transformation alters x- and y-
coordinate values by an amount that is proportional to the z value, while leaving the z
coordinate unchanged, Shear matrix for Z-axis is given below.
x' = x + Sa .z
y '= y + Sb .z
z' = z
x-axis Shear
x' = x
y '= y + Sa .z
z' = x + Sb .z
10 | P a g e timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
y-axis Shear
x' = x + Sa .z
y '= y
z' = x + Sb .z
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
➢ 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.
Types of Projection
1. Parallel Projection
a) Orthographic parallel projection
b) Oblique parallel projection
2. Perspective Projection
➢ Coordinate positions are transformed to view plane along parallel lines (projection
lines)
➢ Preserves relative proportions of objects
11 | P a g e timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
➢ Accurate views of various sides of an object are obtained.
➢ 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
Parallel projection discards z-coordinate and parallel lines from each vertex on the object
are extended until they intersect the view plane. In parallel projection, we specify a
direction of projection instead of centre of projection.
In parallel projection, the distance from the centre of projection to project plane is infinite.
In this type of projection, we connect the projected vertices by line segments which
correspond to connections on the original object.
Parallel projections are less realistic, but they are good for exact measurements. In this
type of projections, parallel lines remain parallel and angles are not preserved.
Orthographic Projection
In orthographic projection the direction of projection is normal to the projection of the
plane. There are three types of orthographic projections
12 | P a g e timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
❖ Front Projection
❖ Top Projection
❖ Side Projection
Oblique Projection
In oblique projection, the direction of projection is not normal to the projection of plane. In
oblique projection, we can view the object better than orthographic projection.
There are two types of oblique projections − Cavalier and Cabinet. The Cavalier
projection makes 45° angle with the projection plane. The projection of a line
perpendicular to the view plane has the same length as the line itself in Cavalier
projection.
The Cabinet projection makes 63.4° angle with the projection plane. In Cabinet projection,
lines perpendicular to the
viewing surface are projected
at ½ their actual length. Both
the projections are shown in
the following figure,
13 | P a g e timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
Isometric Projections
Orthographic projections that show more than one side of an object are called
axonometric orthographic projections. The most common axonometric projection is an
isometric projection where the projection plane intersects each coordinate axis in the
model coordinate system at an equal distance. In this projection parallelism of lines are
preserved but angles are not preserved.
Perspective Projection
In perspective projection, the distance from the centre of projection to project plane is
finite and the size of the object varies inversely with distance which looks more realistic.
The distance and angles are not preserved and parallel lines do not remain parallel.
Instead, they all converge at a single point called centre of projection or projection
reference point. There are 3 types of perspective projections which are shown in the
following chart.
➢ One point perspective projection is simple to draw.
➢ Two-point perspective projection gives better impression of depth.
➢ Three-point perspective projection is most difficult to draw.
14 | P a g e timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
15 | P a g e timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
16 | P a g e timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
4.2. Three-Dimensional Composite Transformations
3-D Transformation is the process of manipulating the view of a three-D object with
respect to its original position by modifying its physical attributes through various methods
of transformation like Translation, Scaling, Rotation, Shear, etc.
As its name suggests itself composite, here we compose two or more than two
transformations together and calculate a resultant(R) transformation matrix by multiplying
all the corresponding transformation matrix conditions with each other.
We can set up a matrix for any sequence of transformations as a composite
transformation matrix by calculating the matrix product of the individual transformations.
Forming products of transformation matrices is often referred to as a concatenation, or
composition, of matrices. For column-matrix representation of coordinate positions, we
form composite transformations by multiplying matrices in order from right to left. That
is, each successive transformation matrix pre multiplies the product of the previous
transformation matrices.
As with two-dimensional transformations. we form a composite three-dimensional
transformation by multiplying the matrix representations for the individual operations in
the transformation sequence. The concatenation is carried out from right to left, where
the rightmost matrix is the first transformation to be applied to an object and the leftmost
matrix is the last transformation.
A sequence of basic, three-dimensional geometric transformations is combined to
produce a single composite transformation, which is then applied to the coordinate
definition of an object. We set up matrices for modelling and other transformations with
functions are similar to two-dimensional transformations. The major difference is that we
can now specify rotations around any coordinate axis. These functions are,
17 | P a g e timilsinadev2007@[Link] |devtimilsina@[Link]
Computer Graphics [Link] [Link] 3rd Sem | Prithivi Narayan Campus Dev Timilsina
Each of these functions produces a 4 by 4 transformation matrix that can then be used to
transform coordinate positions expressed as homogeneous column vector. Parameter
translate Vector is a pointer to the list of translation distances tx, ty and tz. Similarly,
parameter scale Vector specifies the three scaling parameters sx, sy and sz. Rotate and
scale matrices transform objects with respect to the coordinate origin.
And we can construct composite transformations with the functions,
Compose Metrix3
build Transformation Matrix3
compose Transformation Matrix3
which have parameters similar to two-dimensional transformation functions for setting
up composite matrices, except we can now specify three rotation angles. The order of
the transformation sequence for the build Transformation Matrix 3 and compose
Transformation Matrix 3 functions is the same as in two dimensions: (1) scale, (2)
rotate, and (3) translate. Once we have specified a transformation matrix, we can apply
the matrix to specified points with
transformpoint3 (inPoint , matrix, outPoint)
Note: It is similar as a 2D Composite Transformations
18 | P a g e timilsinadev2007@[Link] |devtimilsina@[Link]