Unit 2
Presented By : Tekendra Nath Yogi
Tekendranath@gmail.com
College Of Applied Business And Technology
2/9/2019 1By: Tekendra Nath Yogi
Outline
• Geometrical Transformations
• 2D Transformations:
– Basic transformations :Translation, rotation and scaling
• Matrix Representations and Homogeneous Coordinates
• Composite Transformations :
– Two successive Translations ,Rotations, Scaling
– General Pivot-Point Rotation
– General Fixed-Point Scaling
• Other 2D transformations : reflection, shear
• Two-dimensional viewing:
– Window to View Port Transformation.
• 3D Transformations:
– Basic transformations :Translation, rotation and scaling
– Other transformations: reflection, shear
• 3D Viewing
• Projections
2By: Tekendra Nath Yogi2/9/2019
Geometric Transformation
• Geometric transformation is the process of altering the
coordinate description of objects.
• Purposes:
– To move the position of objects
– To alter the shape / size of objects
– To change the orientation of objects
• Types:
– Rigid Body Transformation( Transformation without deformation of
shape)
– Non Rigid Body Transformation( Transformation with change in
shape)
3By: Tekendra Nath Yogi2/9/2019
Contd….
• Basic 2-D transformations:
– Translation
– Rotation
– Scaling
4By: Tekendra Nath Yogi2/9/2019
Contd….
• Two-Dimensional translation:
– One of rigid-body transformation, which move objects without
deformation.
– Translate an object by Adding translation distances to coordinates to
generate new coordinates positions
– Let,(x, y) be the 2-D point and tx, ty be the translation distance, we
have
– In matrix format, where T is the translation vector
5By: Tekendra Nath Yogi2/9/2019
xtx'x  yty'y 







y
x
P 






y
x
t
t
T






'y
'x
'P
TP'P 
Translating a point from
position P to position P'
with translation vector T.
Contd….
• Example1: Translate the given point (2,5) by translation vector
(3,3)
6By: Tekendra Nath Yogi2/9/2019
Contd….
• Example2: Translate a polygon with coordinates A(2,5), B(7,10) and
C(10,2) by 3 units in x direction and 4 unit in y direction.
• Solution:
7By: Tekendra Nath Yogi2/9/2019
Translated by T(3,4)
Fig: Before translation Fig: After translation
Contd….
• Homework: Translate the triangle with vertices A(2,4), B(1,7)
and C(4,6) by translation vector T(2,4).
8By: Tekendra Nath Yogi2/9/2019
Contd….
• 2-D Rotation:
9By: Tekendra Nath Yogi2/9/2019
Contd….
• Rotation of point position (x, y) when the pivot point (xr, yr) is
at coordinate origin(for positive value of rotation angle):
10By: Tekendra Nath Yogi2/9/2019
Contd….
• The original coordinates of the point in polar coordinates are:
• Transformed coordinates:
• In matrix form:
OR
Where, R is a rotation matrix and is given as:
11By: Tekendra Nath Yogi2/9/2019
cosrx  sinyy 


cossinsinsinsincos)sin('
sincossinsincoscos)cos('
yxrrry
yxrrrx







 



cossin
sincos
R
PR'P 
Contd….
• When coordinate positions are represented as row vectors
instead of column vectors the transformed point (x’, y’ ) is
calculated as:
• i.e.,
12By: Tekendra Nath Yogi2/9/2019
Contd….
• For negative value of rotation angle:
13By: Tekendra Nath Yogi2/9/2019
Contd….
• Example: A point (4,3) is rotated counterclockwise by an
angle 45 degree. Find the rotation matrix and the resultant
point.
• Solution:
14By: Tekendra Nath Yogi2/9/2019
Contd….
• Homework:
– Example2: Rotate the triangle ABC having coordinates A(1,2), B(2,3)
and C(4,5) by 60⁰ about the origin.
– Example3: A point (4,3) is rotated clockwise by an angle -45 degree.
Find the rotation matrix and the resultant point.
– Example4: Rotate the triangle with vertices A(5,8), B(12,10) and
C(10,10) about origin with angle 90 degree in anticlockwise direction.
15By: Tekendra Nath Yogi2/9/2019
Contd….
• 2-D scaling Transformation:
– alters the size of an object.
– carried out for polygons by multiplying the coordinate values (x, y) of
each vertex by scaling factors sx and sy to produce the transformed
coordinates (x', y'):
– scaling factors sx scales object in the x-direction and scaling factor sy
scales object in the y-direction.
– In matrix form:
16By: Tekendra Nath Yogi2/9/2019
xsx'x  ysyy 


















y
x
s0
0s
'y
'x
y
x
PS'P 
Contd….
• Example1: scale the polygon with coordinates A(2,5), B(7,10)
and C(10,2) by two units in x-direction and two units in y-
direction.
17By: Tekendra Nath Yogi2/9/2019
Contd….
18By: Tekendra Nath Yogi2/9/2019
Homework
• Example2: perform the scaling transformation to the triangle
with vertices A(6,9), B(10,5) and C(4,3) with scaling factors
sx=3 and sy=2.
• Example3:scale the rectangle ABCD with vertices A(2,2) ,
B(2,6), C(5,2) ad D(5,6) to double its size.
• Example4: perform the scaling transformation to the triangle
with vertices A(6,10), B(10,6) and C(4,2) with scaling factors
sx=0.5 and sy=0.5.
19By: Tekendra Nath Yogi2/9/2019
Matrix Representations and Homogeneous coordinates
• Many graphics applications involve sequences of geometric
transformations
– E.g., In design and picture construction applications, we perform
translations, rotations, and scaling to fit the picture components into
their proper positions.
• But this sequential transformation process is not efficient.
• Solution: Use homogeneous coordinate system!
20By: Tekendra Nath Yogi2/9/2019
Contd….
•What is homogeneous coordinates?
– A point (x, y) can be re-written in homogeneous coordinates as (xh, yh,
h)
– The homogeneous parameter h is a non- zero value such that:
– We can then write any point (x, y) as (h*x, h*y, h)
– We can conveniently choose h = 1 so that (x, y) becomes (x, y, 1)
21By: Tekendra Nath Yogi2/9/2019
h
x
x h

h
y
y h

Contd….
• Homogeneous coordinate system allows us to express
transformation equations as matrix multiplication.
• The homogeneous coordinates allow combined transformation,
eliminating the calculation of intermediate coordinate values
and thus save required time for transformation and memory
required to store the intermediate coordinate values.
22By: Tekendra Nath Yogi2/9/2019
Contd….
• Homogeneous coordinate for translation:
• Alternatively,
23By: Tekendra Nath Yogi2/9/2019































1100
10
01
1
'
'
y
x
t
t
y
x
y
x
Contd….
• Homogeneous coordinates for Rotation:
• Alternatively,
24By: Tekendra Nath Yogi2/9/2019



















 











1100
0cossin
0sincos
1
'
'
y
x
y
x


Contd….
• Homogeneous coordinates for scaling
• Alternatively,
25By: Tekendra Nath Yogi2/9/2019































1100
00
00
1
'
'
y
x
s
s
y
x
y
x
Inverse transformations:
• Inverse translation:
– The inverse translation matrix can be obtained by replacing the
translation distances tx and ty with their negatives: -tx and –ty.
– i.e.,
– So,
26By: Tekendra Nath Yogi2/9/2019













100
t10
t01
T y
x
1

































1100
10
01
1
'
'
y
x
t
t
y
x
y
x
Contd….
• Inverse Rotation:
• The inverse rotation matrix can be obtained by replacing the rotation angle with
its negative value.
• i.e.,
• So,
27By: Tekendra Nath Yogi2/9/2019











100
0cossin
0sincos
R 1

































1100
0cossin
0sincos
1
'
'
y
x
y
x


Contd….
• Inverse scaling:
– Inverse scaling matrix can be obtained by replacing sx and sy by 1/sx
and 1/sy respectively.
– i.e.,
– So,
28By: Tekendra Nath Yogi2/9/2019

















100
0
1
0
00
1
1
sy
s
S
x































1100
0/10
00/1
1
'
'
y
x
s
s
y
x
y
x
Composite transformations
• The basic purpose of composite transformations is to gain
efficiency by applying a single composed transformation to a
point, rather than applying a series of transformations, one
after the other.
29By: Tekendra Nath Yogi2/9/2019
Contd…
• Two successive Translations:
– If two successive translation distances (tx1, ty1) and (tx2, ty2) are applied
to coordinate position P, the final transformed location P’ is calculated
as:
– The composite transformation matrix for this sequence of translation is:
– Or
– Which demonstrates that two successive translations are additive.
30By: Tekendra Nath Yogi2/9/2019
PttTttT
PttTttTP
yxyx
yxyx
)}.,().,({
}).,().{,('
1122
1122



































100
10
01
100
10
01
.
100
10
01
21
21
1
1
2
2
yy
xx
y
x
y
x
tt
tt
t
t
t
t
),(),().,( 21211122 yyxxyxyx ttttTttTttT 
Contd…
• Two successive rotations:
– For Successive Rotations θ1 and θ2
– Successive Rotations are additive. i.e.,
– Now proving this statement:
31By: Tekendra Nath Yogi2/9/2019
PRR
PRRP
)}.().({
}).().{('
12
12




)()().( 2112   RRR
Contd…
• Which demonstrates that two successive rotations are additive.
• So the final rotated coordinates can be calculated with the composite
rotation matrix as:
32By: Tekendra Nath Yogi2/9/2019
PRP ).(' 21  
Contd…
• Two successive scaling:
– Successive Scaling are multiplicative
– Or,
33By: Tekendra Nath Yogi2/9/2019































100
0.0
00.
100
00
00
.
100
00
00
21
21
1
1
2
2
yy
xx
y
x
y
x
ss
ss
s
s
s
s
).,.(),().,( 21211122 yyxxyxyx ssssSssSssS 
Contd…
• General Pivot Rotation: can generate rotations about an
arbitrary point (xr, yr) by performing the following sequence of
translate-rotate-translate operations:
– Translate the object so that the pivot-point position is moved to the
coordinate origin.
– Rotate the object about the coordinate origin.
– Translate the object so that the pivot point is returned to its original
position.
34By: Tekendra Nath Yogi2/9/2019
Contd…
• This transformation sequence is illustrated in the following fig:
35By: Tekendra Nath Yogi2/9/2019
Contd…
36By: Tekendra Nath Yogi2/9/2019
Contd…
• Example: Rotate the triangle having coordinates (1,2),(2,3)
and (4,5) by 60⁰ about (2,3).
• Example: perform the counterclockwise 45O rotate of triangle
A(2,3), B(5,5), C(4,3) about point (3,4).
37By: Tekendra Nath Yogi2/9/2019
Contd…
• General fixed point scaling:
– Translate object so that the fixed point coincides with the coordinate
origin.
– Scale the object with respect to the coordinate origin.
– Use the inverse translation of step 1 to return the object to its original
position.
38By: Tekendra Nath Yogi2/9/2019
Contd…
• The above transformation sequence to achieve fixed point scaling is
illustrated in the following fig:
39By: Tekendra Nath Yogi2/9/2019
Homework
• Example: Find the transformation matrix that transforms the
given square ABCD to half its size about (2,2,). The
coordinates of the square are A(1,1), B(3,1), C(3,3) and
D(1,3).
40By: Tekendra Nath Yogi2/9/2019
Homework
• Example: Rotate ∆ABC by 45⁰ clockwise about the origin and
scale it by (2,3) about the origin.
• Example: Rotate ∆ABC by 90⁰ anti-clockwise about the (5,8)
and scale it by (2,2) about (10,10).
41By: Tekendra Nath Yogi2/9/2019
Other 2-D Transformations
• Reflection
• Shear
42By: Tekendra Nath Yogi2/9/2019
Reflection
• A reflection is a transformation that produces a mirror image
of an object.
• The mirror image for a two-dimensional reflection is
generated relative to an axis of reflection by rotating the object
180 degree about the reflection axis.
43By: Tekendra Nath Yogi2/9/2019
Contd…
• Reflection about x-axis:
– Also known as reflection about line y=0
– Change the sign of y coordinate but x-coordinate remains same
• X’= X
• Y’=- Y
– In matrix form
– Equivalent to 180O rotation
about x-axis
44By: Tekendra Nath Yogi2/9/2019
Contd…
• Reflection about y-axis:
– Also known as reflection about line x=0.
• Change the sign of x-coordinate but y-coordinate remains same
• X’= -X
• Y’= Y
– In matrix form:
– Equivalent to 180O rotation
about y-axis
45By: Tekendra Nath Yogi2/9/2019
Contd…
• Reflection about origin:
– Also known as reflection about axis that is perpendicular to xy-plane
and that passes through the coordinate origin.
– Change the sign of both x-coordinate and y-coordinate.
» x’=-x
» y’=-y
– In matrix form:
– Equivalent to 180O rotation
about origin
46By: Tekendra Nath Yogi2/9/2019
Contd…
• Reflection about arbitrary fixed point:
– same as a 180o rotation in the xy plane using the reflection point as the
pivot point.
47By: Tekendra Nath Yogi2/9/2019
Contd…
• Reflection about a diagonal line y=x: can be obtained by
performing following sequence of transformations:
– Clock wise Rotation with 450
– reflection with x-axis
– Inverse rotation with 450
48By: Tekendra Nath Yogi2/9/2019










100
001
010
Contd…
49By: Tekendra Nath Yogi2/9/2019
1. first perform a clockwise rotation through a 45"
angle
2.Next, we perform a reflection with respect to the x
axis.
3. back to its original position with a counterclockwise
rotation through 45".
Contd…
• Reflection about a diagonal line y=-x:
– Can be obtained by performing the following sequence of
transformations:
• clockwise rotation
• reflection about the y axis, and
• counterclockwise rotation .
50By: Tekendra Nath Yogi2/9/2019












100
001
010
Contd…
• Reflections about any line y = mx+ c in the xy plane:
– can be accomplished with a combination of :
1. translate the Line so that it passes through the origin i.e., T(0, -c)
2. rotate the line onto one of the coordinate axes and reflect about
that axis. i.e.,
1. R(-theta)
2. Reflection with coordinate axis-axis
3. restore the line to its original position with the inverse rotation
and translation transformations i.e.,
1. R(theta)
2. T(0.c)
51By: Tekendra Nath Yogi2/9/2019
Contd…
• Example: Find out final transformation matrix, when point
p(x, y) is to be reflected about a line y= mx+c.
• Solution:
52By: Tekendra Nath Yogi2/9/2019
Contd…
53By: Tekendra Nath Yogi2/9/2019
Contd…
54By: Tekendra Nath Yogi2/9/2019
Contd…
55By: Tekendra Nath Yogi2/9/2019
Contd…
56By: Tekendra Nath Yogi2/9/2019
Contd…
• Question: Determine the transformation for reflection about
y=x+3
57By: Tekendra Nath Yogi2/9/2019
Contd…
• Question: Translate the given triangle A(1,3), B(-2,-1) and
C(6,-2) with translation vector T(-2,-6) and then reflect about
y=x axis.
58By: Tekendra Nath Yogi2/9/2019
Shearing
59By: Tekendra Nath Yogi
A transformation that distorts the shape of an object.
2/9/2019
Cont…
60By: Tekendra Nath Yogi2/9/2019
Homework
1. Scale the rectangle ABCD with vertices A(2,2),B(2,6), C(5,2) and D(5,6) to double its
size about fixed point (2,3) then translate it using translation vector (1,3).
2. Rotate the triangle ABC with vertices A(3,5), B(7,2) and C(4,9) in counterclockwise
direction by 90 degree and then enlarge it to double its size.
3. A unit square is located at origin shear it along horizontal direction with shearing
coefficient 2.
4. Find out the final coordinates of a figure bounded by the coordinate (1,1), (3,4), (5,7),
(10,3) when rotated about a point (8,8) by 30 degree in clockwise direction and scaled
by two units in x-direction and three units y-direction.
5. Show that 2D reflection through x-axis followed by 2-D reflection through the line y=-
x is equivalent to a pure rotation about the origin.
6. Show that transformation matrix for reflection about a line y=x is equivalent to
reflection to x-axis followed by counter clockwise rotation of 90degree.
7. Reflect rectangle PQRS, P(1,2), Q(1,6), R(9,6) and S(9,2) on y=5 axis, then scale about (2,3) with scale
factor (4,2) and finally rotate with rotation angle +45o about origin. Use homogenous coordinate system
to calculate transformed rectangle coordinates.
61By: Tekendra Nath Yogi2/9/2019
3D Transformations
Presented By : Tekendra Nath Yogi
Tekendranath@gmail.com
College Of Applied Business And Technology
2/9/2019 62By: Tekendra Nath Yogi
3D Transformations
• Extend from two-dimensional transformation by including
considerations for the z coordinates.
• Translation and scaling are similar to two-dimension, include the three
Cartesian coordinates
• Rotation method is less straight forward
• The most common 3D transformations are:
– Translation
– Rotation
– Scaling
– Reflection and
– shears
63By: Tekendra Nath Yogi2/9/2019
Contd…
• Three-dimensional translation:
• A point P (x, y, z) in three-dimensional space translate to new
location p’(x’, y’, z’) with the translation distance T (tx, ty, tz) as :
• In matrix form:
64By: Tekendra Nath Yogi2/9/2019
xtx'x  yty'y 






































11000
100
010
001
1
'
'
'
z
y
x
t
t
t
z
y
x
z
y
x
PT'P 
ztz'z 
Contd…
• Questions: Translate the 3D square with vertices A(4,5,7), B(-
3,-2,1) , C(2,4,7) and D(-5,3,2) using translation vector (1,3,4).
65By: Tekendra Nath Yogi2/9/2019
Contd…
• Three-dimensional scaling:
– Relative to the coordinate origin, just include the parameter
for z coordinate scaling in the transformation matrix
– Relative to a fixed point (xf, yf zf)
• Perform a translate-scaling-translate composite transformation
66By: Tekendra Nath Yogi2/9/2019

















1000
)1(00
)1(00
)1(00
),,(),,(),,(
fzz
fyy
fxx
fffzyxfff
zss
yss
xss
zyxTsssSzyxT
PS'P 






































1
z
y
x
1000
0s00
00s0
000s
1
'z
'y
'x
z
y
x
Contd…
• The sequence of transformations for fixed point scaling is demonstrated in
Fig below.
67By: Tekendra Nath Yogi2/9/2019
Contd…
• Question1: A 3D object with vertices A(-2,-4,4), B(3,-6, -8), C(-
6,1,0) and D(3.-6.2) is required to scale with scale factor S(2,4,6)
about origin. Find the final coordinates.
• Question2: Given a solid PQT , p( 2,-5,0), Q(4,-2,3) and T(6,-7,-1)
is translated with T(9,0,-2) and then scale about origin with scaling
factor (2,4,5). Find the final coordinates.
• Question3: suppose we have a quadrilateral ABCD with vertices
A(3,1,4), B(-7,-4,2) C(5, -8, -3) and D(3,0,1). What is the
coordinates of quadrilateral if it is to be doubled in size about origin.
Then translate obtained coordinates with (-4,3,1)
• Question 4: scale the triangle with vertices A(-3,-2,1), B(4,5,6),
C(5,7,9) to double its size about fixed point (1,2,3).
68By: Tekendra Nath Yogi2/9/2019
3D Rotation
• To generate a rotation transformation for an object, we
must designate an axis of rotation (about which the object
is to be rotated) and the amount of angular rotation.
• Axis of rotation can be:
– Coordinate axis
– Parallel axis, or
– Arbitrary axis.
• Angle of rotation( ) can be:
– Positive : indicate counter clock wise rotation, or
– Negative: indicate the clock wise rotation.
69By: Tekendra Nath Yogi2/9/2019
Coordinate-Axes Rotations:
• A) Rotation about Z-axis
70By: Tekendra Nath Yogi2/9/2019
Contd..
• Any point p(x, y, z) can be rotated about z-axis with angle as
follows:
• In matrix form:
71By: Tekendra Nath Yogi
























 













1
z
y
x
1000
0100
00cossin
00sincos
1
'z
'y
'x


zz
yxy
yxx



'
cossin'
sincos'


PRP z ).(' 












 

1000
0100
00cossin
00sincos
)(


zR
2/9/2019
Contd..
• B) Rotation About X-axis
72By: Tekendra Nath Yogi2/9/2019
Contd..
• Any point p(x, y, z) can be rotated about x-axis with angle as
follows:
• In matrix form:
73By: Tekendra Nath Yogi
 














1000
0cossin0
0sincos0
0001


xx RR
x'x
coszsiny'z
sinzcosy'y











































1
.
1000
0cossin0
0sincos0
0001
1
'
'
'
z
y
x
z
y
x


PRP x ).(' 

2/9/2019
Contd..
• C) Rotation About Y-axis
74By: Tekendra Nath Yogi2/9/2019
Contd..
• Any point p(x, y, z) can be rotated about y-axis with angle as
follows:
• In matrix form:
75By: Tekendra Nath Yogi
y'y
cosxsinz'x
sinxcosz'z





 














1000
0cos0sin
0010
0sin0cos


yy RR






































1
.
1000
0cos0sin
0010
0sin0cos
1
'
'
'
z
y
x
z
y
x


PRP y ).(' 

2/9/2019
Contd…
• Question1: A coordinate point p(3,2,1) is translated in x, y and z direction
by -2, -2 and -2 unit respectively followed by rotation with 60o about x-
axis. Find the final position of a point
• Question 2: A cube of length 10 units having one of its corner at origin (0,
0, 0) and three edges along three principle axis. If the cube is to be rotated
about z-axis by an angle of 45 degree in counterclockwise direction, then
calculate the new position of the cube.
• Question 3: The pyramid defined by the coordinates A(0,0,0) B(1,0,0),
C(0,1,0) and D(0,0,1) is scaled to double its size about point (0,1,0), then
translated to new position by translation vector (4,5,6) and rotated by angle
45 degree in clockwise direction about origin. Use homogeneous
transformation matrix to find the new vertices of pyramid.
76By: Tekendra Nath Yogi2/9/2019
Contd..
• Rotation about axis parallel to coordinate axis
– when an object is to be rotated about an axis that is
parallel to one of the coordinate axes, we can attain the
desired rotation with the following transformation
sequence.
• Translate the object so that the rotation axis coincides with the
parallel coordinate axis.
• Perform the specified rotation about that axis.
• Translate the object so that the rotation axis is moved back to its
original position.
77By: Tekendra Nath Yogi2/9/2019
Contd..
• The sequence of transformations for rotation about axis parallel to
coordinate axis(e.g.., x-axis) is demonstrated in figure below:
step1
step2
step3
78By: Tekendra Nath Yogi2/9/2019
Contd..
• Rotation about arbitrary axis that is not parallel to
one of the coordinate axes :
– when an object is to be rotated about an axis that is not parallel to one of
the coordinate axes, we can attain the desired rotation with the following
transformation sequence.
79By: Tekendra Nath Yogi2/9/2019
Contd..
– Translate the object so that the rotation axis passes through the coordinate
origin.
– Rotate the object so that the axis of rotation coincides with one of the coordinate
axes.
– perform the specified rotation about that coordinate axis.
– Apply inverse rotation to bring the rotation axis back to its original orientation.
– Apply the inverse translation to bring the rotation axis back to its original
position.
80By: Tekendra Nath Yogi2/9/2019
Contd..
81By: Tekendra Nath Yogi
Fig: Five transformation steps for obtaining a composite matrix for rotation about arbitrary axis,
with the rotation axis projected onto the z-axis2/9/2019
Contd…
82By: Tekendra Nath Yogi2/9/2019
Contd…
83By: Tekendra Nath Yogi2/9/2019
Contd…
84By: Tekendra Nath Yogi2/9/2019
Contd…
85By: Tekendra Nath Yogi2/9/2019
Contd…
86By: Tekendra Nath Yogi2/9/2019
Contd…
• Example: Find the new co-ordinates of a unit cube 90 degree
rotated about an axis defined by its end points A(2,1,0) and
B(3,3,1).
87By: Tekendra Nath Yogi2/9/2019
A unit cube
Contd…
88By: Tekendra Nath Yogi2/9/2019
Contd…
89By: Tekendra Nath Yogi2/9/2019
Contd…
90By: Tekendra Nath Yogi2/9/2019
Contd…
91By: Tekendra Nath Yogi2/9/2019
Contd…
92By: Tekendra Nath Yogi2/9/2019
Contd…
93By: Tekendra Nath Yogi2/9/2019
Contd…
• Question1: Rotate triangle with vertices A(), B(0,2,1),(2,3,0)
and (1,2,1) about the line joining the point (0,0,0) and (1,1,1)
with the angle of rotation 450 in counter clockwise direction.
• Question1: Rotate triangle with vertices A(0,2,1),B(2,3,0)
and C(1,2,1) about the line joining the point (2,2,2) and (1,1,1)
with the angle of rotation 450 in counter clockwise direction.
94By: Tekendra Nath Yogi2/9/2019
Reflections
• A three-dimensional reflection can be performed relative to a
selected reflection axis or with respect to a selected refection plane.
• Reflections relative to a given axis are equivalent to 18o0 rotations
about that axis.
• Reflections with respect to a plane are equivalent to 1800 rotations
in four-dimensional space.
• Reflection plane can be a coordinate plane (either xy, xz, or yz)
95By: Tekendra Nath Yogi2/9/2019
Contd…
• Reflection in xy plane:
• This transformation changes the sign of the z coordinates, Leaving the x
and y-coordinate values unchanged.
– x’ = x
– y’ = y
– z’ = -z
• The matrix representation for this reflection of points relative to the x-y
plane is:
96By: Tekendra Nath Yogi2/9/2019
Contd…
• Reflection in yz plane:
– This transformation changes the sign of the x coordinates, Leaving the
z and y-coordinate values unchanged.
• x’ = -x
– y’=y
– z’=z
– The matrix representation for this reflection of points relative to the x-y
plane is:
97By: Tekendra Nath Yogi2/9/2019
Contd…
Reflection in XZ plane:
– This transformation changes the sign of the y coordinates, Leaving the
z and x-coordinate values unchanged.
– y’= -y
– x’=x
– z’=z
– The matrix representation for this reflection of points relative to the x-y
plane is:
98By: Tekendra Nath Yogi2/9/2019
Shears
• Shearing transformations produce distortions in the shapes of
objects.
• The transformation equations for a Z-axis shear is :
– x’ = x + a.z
– y’ = y + b.z
– z’ = z
The matrix representation for a z-axis shear is:
99By: Tekendra Nath Yogi





































1
.
1000
0100
010
001
1
'
'
'
z
y
x
b
a
z
y
x
2/9/2019
Contd…
• Similarly, The matrix representation for a x-axis shear is:
• The matrix representation for a y-axis shear is:
100By: Tekendra Nath Yogi2/9/2019





































1
.
1000
010
001
0001
1
'
'
'
z
y
x
b
a
z
y
x





































1
.
1000
010
0010
001
1
'
'
'
z
y
x
b
a
z
y
x
Contd…
• Question1: shear the triangle with vertices A(1,2,1), B(5,4,7)
and C(3,6,9) about x-axis using shearing coefficient shy=3 and
shz=5.
101By: Tekendra Nath Yogi2/9/2019
2D viewing
• Pictures are stored in memory using Cartesian coordinate
system referred to as world coordinate system.
• But, pictures are displayed in display device using physical
device coordinate system.
• So, to display picture requires the transformation from world
coordinate to device coordinate.
• This mapping of coordinate can be achieved with the use of
viewing transformation.
102By: Tekendra Nath Yogi2/9/2019
Contd…
• window :
– A world-coordinate area selected for display is called a window.
– defines what is to be viewed
• viewport :
– An area on a display device to which a window is mapped is called a
viewport.
– defines where it is to be displayed.
103By: Tekendra Nath Yogi2/9/2019
Contd..
• viewing transformation:
– The mapping of a part of a world-coordinate scene to device
coordinates is referred to as a viewing transformation.
– 2D viewing transformation referred to as the window-to-viewport
transformation or the windowing transformation.
104By: Tekendra Nath Yogi2/9/2019
Fig: A viewing transformation using standard rectangles for the window and viewport.
Contd…
• viewing pipeline:
– Takes the object coordinates through several intermediate coordinates
systems before finishing with device coordinates as shown in figure
below:
105By: Tekendra Nath Yogi2/9/2019
Fig: The 2D viewing-transformation pipeline
Window to Viewport Transformation
• A point at position (xw, yw) in a designated window is mapped to
viewport coordinates (xv, yv) so that relative positions in the two
areas are the same.
• i.e., If a coordinate position is at the center of the viewing window, for
instance, it will be displayed at the center of the viewport.
106By: Tekendra Nath Yogi2/9/2019
Contd…
• To maintain the same relative placement, the following ratios
must be equal.
107By: Tekendra Nath Yogi2/9/2019
minmax
min
minmax
min
minmax
min
minmax
min
ywyw
ywyw
yvyv
yvyv
xwxw
xwxw
xvxv
xvxv










Contd…
• By solving these equations for the unknown viewport position
(xv, yv):
• Where the scaling factors are:
108By: Tekendra Nath Yogi2/9/2019
syywywyvyv
sxxwxwxvxv
)(
)(
m inm in
m inm in


m inm ax
m inm ax
m inm ax
m inm ax
ywyw
yvyv
xwxw
xvxv
sy
sx






Contd…
• Given a window and viewport, what is the transformation
matrix that maps the window from world coordinates into the
viewport in screen coordinates?
• This matrix can be developed by three step transformation
composition as:
– The object together with its widow is translated until the lower left
corner of the window is at the origin.
– Object and window are scaled until the window has the dimension of
the viewport.
– Translate the viewport to its correct position on the screen.
109By: Tekendra Nath Yogi2/9/2019
Contd…
• Above three steps are illustrated in the following figure:
110By: Tekendra Nath Yogi2/9/2019
step0.
Step 3.step2.
step1.
Contd…
• Step1: translation
111By: Tekendra Nath Yogi2/9/2019













100
10
01
min
min
w
W
Y
X
T
Contd…
• Step2: scaling about origin
• Where,
112By: Tekendra Nath Yogi2/9/2019
minmax
minmax
minmax
minmax
ywyw
yvyv
xwxw
xvxv
sy
sx

















100
00
00
y
x
s
s
S
Contd…
• Step 3: inverse translation
113By: Tekendra Nath Yogi2/9/2019











100
10
01
)( min
min
v
v
Y
X
Tinverse
Contd…
• The overall transformation matrix for window to viewport
transformation is:
114By: Tekendra Nath Yogi2/9/2019













100
).(0
).(0
minmin
minmin
syywyvs
sxxwxvs
y
x












100
10
01
min
min
w
W
Y
X










100
00
00
y
x
s
s











100
10
01
min
min
v
v
Y
X
Contd…
• Example:
115By: Tekendra Nath Yogi2/9/2019
Contd…
• Step2: calculating the scaling factor and then scaling
transformation matrix
• Sx=(1-0.5)/(20-10)=0.5/10= 0.05
• Sy=(1-0.5)/(20-10)= 0.5/10= 0.05
116By: Tekendra Nath Yogi2/9/2019
Contd…
• Step3: Inverse translation matrix to maintain the relative
position in view port is:
117By: Tekendra Nath Yogi2/9/2019
Contd…
• So, the final composite view transformation matrix is:
118By: Tekendra Nath Yogi2/9/2019
0 0
Contd…
• Example1: Translate the triangle with vertices A(10,10), B(20, 30), and
C(15,20) from window to viewport where window is defined by xwmin=50,
xwmax=100, ywmin=20 and ywmax=100 and viewport is defined as xvmin=20,
xvmax=45, yvmin=40 and yvmax=80
• Example2: Translate the triangle with vertices A(2,2), B(3, 5), and C(5,8)
from window to viewport where window is defined by xwmin=1, xwmax=6,
ywmin=2 and ywmax=10 and viewport is defined as xvmin=0, xvmax=2
yvmin=0 and yvmax=4
• Example3: consider the window is located from 0 to 100 and a point is
located in (30, 30). Identify the point position in the viewport located from
0 to 50.
119By: Tekendra Nath Yogi2/9/2019
Clipping
Presented by: Tekendra Nath Yogi
Tekendranath@gmail.com
College of applied business and technology
2/9/2019 120By: Tekendra Nath Yogi
Clipping
• Any procedure that identifies those portions of a picture that are either
inside or outside of a specified region of a space is referred to as
clipping.
• The region against which an object is to be clipped is called a clip
window. Depending on the application a clip window can be polygon or
curved boundaries.
• World- coordinate clipping removes the primitives outside the window
from further consideration; thus eliminating the processing necessary to
transform these primitives to device space.
• Clipping type- point ,line, polygon, curved areas and etc.
121By: Tekendra Nath Yogi2/9/2019
Contd…
• Applications of clipping include:
– Extracting part of a defined scene for viewing
– Identifying visible surfaces in three-dimensional views
– Antialiasing line segments or object boundaries
– Creating objects using solid-modeling procedures
– Displaying a multi-window environment
– Drawing and painting operations that allow parts of a picture to be
selected for copying, moving, erasing, or duplicating.
122By: Tekendra Nath Yogi2/9/2019
Point Clipping
• In a rectangular clip window save a point P = (x, y) for display(i.e., not clipped)
if the following inequalities are satisfied:
• Xwmin ≤ x ≤ xwmax
• ywmin ≤ y ≤ ywmax
• If any one of these four inequalities is not satisfied, the point is clipped
(not saved for display).
• The equal sign indicates that point on the window boundary are included within
the window.
123By: Tekendra Nath Yogi2/9/2019
Contd…
2/9/2019 124By: Tekendra Nath Yogi
Line clipping
• The visible segment of a straight line can be determined by
inside – outside test:
– A line with both endpoints inside clipping boundary, such as the line
from p1 to p2, is saved.
125By: Tekendra Nath Yogi2/9/2019
Contd…
• A line with both endpoints outside the clip boundary, such as
the line from p3 to p4, is not saved.
126By: Tekendra Nath Yogi2/9/2019
Contd…
• If the line is not completely inside or completely outside (e.g., p7 to p8 ),
then perform intersection calculations with one or more clipping
boundaries.
127By: Tekendra Nath Yogi2/9/2019
Cohen-Sutherland Line Clipping
• This algorithm clips the line by performing following steps:
• Step1: Region code assignment
– divide the whole picture region into nine regions by extending the window
boundaries as shown in figure below and then assign a 4-bit region code to
each region as follows:
1001 1000 1010
0001
0000
Window
0010
0101 0100 0110
Rules For assigning region code:
T=1 , if the region is above the window,
= 0 , otherwise.
B= 1, if the region is below the window,
= 0, otherwise.
R=1, if the region is right of window,
= 0, otherwise.
L= 1, if the region is left of window,
= 0, otherwise.
128By: Tekendra Nath Yogi2/9/2019
Contd…
• Every end-point is labelled with the appropriate region code
• For example:
wymax
wymin
wxmin wxmax
Window
P3 [0001]
P6 [0000]
P5 [0000]
P7 [0001]
P10 [0100]
P9 [0000]
P4 [1000]
P8 [0010]
P12 [0010]
P11 [1010]
P13 [0101] P14 [0110]
129By: Tekendra Nath Yogi2/9/2019
Contd…
• Step2: Trivial acceptance of line segment
– Lines completely contained within the window boundaries have region code
[0000] for both end-points so are not clipped. i.e., accept these lines
trivially.
– E.g., line p5p6
wymax
wymin
wxmin wxmax
Window
P3 [0001]
P6 [0000]
P5 [0000]
P7 [0001]
P10 [0100]
P9 [0000]
P4 [1000]
P8 [0010]
P12 [0010]
P11 [1010]
P13 [0101] P14 [0110]
130By: Tekendra Nath Yogi2/9/2019
• Step3: Trivial rejection and clipping
– 3.1 : Any lines that have a 1 in the same bit position in the
region-codes for each endpoint are completely outside and we
reject these lines.
– The AND operation can efficiently check this: If the logical AND of both
region codes result is not 0000, the line is completely outside the
clipping region so clipped.
Contd…
wymax
wymin
wxmin wxmax
Window
P3 [0001]
P6 [0000]
P5 [0000]
P7 [0001]
P10 [0100]
P9 [0000]
P4 [1000]
P8 [0010]
P12 [0010]
P11 [1010]
P13 [0101] P14 [0110]
131By: Tekendra Nath Yogi2/9/2019
3.2:If the logical AND operation results in 0000 then
a) Choose an endpoint of the line that is outside the window.
b) Find the intersection point at the window boundary by using the
following formula:
c) Replace endpoint with the intersection point and update the region code.
Above process is repeated until we find a clipped line either trivially accepted
or trivially rejected.
Contd…
132By: Tekendra Nath Yogi2/9/2019
Contd…
• Algorithm:
133By: Tekendra Nath Yogi2/9/2019
Contd..
• Example: Use the Cohen-Sutherland line clipping algorithm to clip line
defined with end points p1(0,120) and (130,5) against a window defined by the
following four points : (10,10), (10,100), (150,10) and (150,100)
134By: Tekendra Nath Yogi2/9/2019
Contd…
• Solution:
135By: Tekendra Nath Yogi2/9/2019
Contd…
136By: Tekendra Nath Yogi2/9/2019
Contd…
137By: Tekendra Nath Yogi2/9/2019
Contd…
138By: Tekendra Nath Yogi2/9/2019
• Example1: Let ABCD be the rectangular window with A(20, 20), B(90,
120), C(90, 70), and D(20,70). Find the region codes for end points and
use Cohen- Sutherland algorithm to clip the line p q with p( 10,30) and
q(80, 90).
• Example2: Use the Cohen-Sutherland algorithm to clip line defined with
end points p1(40,15) and p2(75,45) against a window A(50,10),
B(80,10), C(80,40) and D(50,40).
• Example3: Use the Cohen-Sutherland algorithm to clip line defined with
end points p1(70, 20) and p2(100,10) against a window A(50,10),
B(80,10), C(80,40) and D(50,40).
By: Tekendra Nath Yogi 139
Homework
2/9/2019
Polygon Clipping
• Polygon clipping algorithm generates one or more closed bounded areas as
shown in figure below:
By: Tekendra Nath Yogi 1402/9/2019
Contd…
• Sutherland-Hodgman Polygon Clipping:
– Begin with the initial set of polygon vertices, first clip the polygon against
the left rectangle boundary to produce a new sequence of vertices.
• The new set of vertices could be successively passed to a right boundary
clipper, a bottom boundary clipper, and a top boundary clipper as shown in
figure below.
By: Tekendra Nath Yogi 1412/9/2019
142
Contd…
Left
Clipper
Right
Clipper
Bottom
Clipper
Top Clipper
At each step, a new sequence of output vertices is generated and passed to the next
window boundary clipper.
2/9/2019
By: Tekendra Nath Yogi
As each pair of adjacent polygon vertices is passed to a next window
boundary clipper, we make the following tests:
1. If the first vertex is outside the window boundary and the second vertex
is inside Then , both the intersection point of the polygon edge with the
window boundary and the second vertex are added to the output vertex
list.
For example:
v1- outside and
v2- inside
Movement is out in
Output vertex – intersection point v1’ and
destination point v2
By: Tekendra Nath Yogi 1432/9/2019
Contd…
2. If both input vertices are inside the window boundary. Then,
only the second vertex is added to the output vertex list.
• For example:
– v1- inside
– V2- inside
– Movement in in
– Output vertex = destination vertex
– Therefore save V2
By: Tekendra Nath Yogi 1442/9/2019
Contd…
3. If the first vertex is inside the window boundary and the second
vertex is outside. Then, only the edge intersection with the
window boundary is added to the output vertex list.
• For Example:
– V1-inside
– V2- outside
– Movement = in out
– Therefore, save v1’
By: Tekendra Nath Yogi 1452/9/2019
Contd….
4. If both input vertices are outside the window boundary.
Then, nothing is added to the output vertex list.
• For Example:
– V1- outside
– V2- outside
– Movement = out out
– Therefore, save nothing
By: Tekendra Nath Yogi 146
2/9/2019
Contd…
• Example1 :We illustrate this algorithm by processing the area in figure against
the left window boundary.
• Vertices 1 and 2 are outside of the boundary.
• Vertex 3, which is inside, 1' and vertex 3 are saved.
• Vertex 4 and 5 are inside, and they also saved.
• Vertex 6 is outside, 5' is saved.
• Using the five saved points, we would repeat the process for the next window
boundary.
By: Tekendra Nath Yogi 1472/9/2019
Contd…
• Example2: clip polygon ABCDE against window PQRS. The
coordinate of the polygon are A(80, 200), B(220, 120), C( 150,
100), D(100, 30), E(10, 120). Coordinates of the window are
P(200,50), Q(50, 150), R(200, 150), S(50, 50).
By: Tekendra Nath Yogi 1482/9/2019
Homework
• Example 3: You are provided with the clipping rectangle with co-
ordinates A(10, 10), B(10, 20), C(20, 10) and D(20, 20). Clip the
given polygon PQRS with coordinates P(5, 15), Q(15, 25), R(15,
15) and S(10, 10) using Sutherland - Hodgeman polygon clipping
algorithm.
By: Tekendra Nath Yogi 1492/9/2019
Curve Clipping
• The bounding rectangle for a circle or other curved object can
be used first to test for overlap with a rectangular clip window.
• If the bounding rectangle for the object is completely inside
the window, we save the object.
• If the rectangle is determined to be completely outside the
window, we discard the object. In either case, there is no
further computation necessary.
• But if the bounding rectangle test fails, we can look for other
computation-saving approaches.
150By: Tekendra Nath Yogi2/9/2019
Contd…
• For a circle, we can use the coordinate extents of individual
quadrants and then octants for preliminary testing before
calculating curve-window intersections.
• For an ellipse, we can test the coordinate extents of individual
quadrants.
151By: Tekendra Nath Yogi2/9/2019
Contd…
• Figure below illustrates circle clipping against a rectangular
window.
152By: Tekendra Nath Yogi2/9/2019
Contd…
• Similar procedures can be applied when clipping a curved
object against a general polygon clip region.
• On the first pass, we can clip the bounding rectangle of the
object against the bounding rectangle of the clip region.
• If the two regions overlap, we will need to solve the
simultaneous line-curve equations to obtain the clipping
intersection points.
153By: Tekendra Nath Yogi2/9/2019
Homework
1. What is clipping? Explain the polygon clipping algorithm with suitable
example.
2. Where do you require ellipse clipping algorithm? Explain in detail about
ellipse clipping algorithm.
3. Why clipping is required in computer graphic? Explain the circle clipping
algorithm.
2/9/2019 154By: Tekendra Nath Yogi
3D viewing
Presented by: Tekendra Nath Yogi
Tekendranath@gmail.com
College of applied business and technology
2/9/2019 155By: Tekendra Nath Yogi
Introduction
• 2D viewing transfers position from the world coordinate plane
to plane of the output device.
• But in 3D viewing such direct transformation is not possible
due to the different views of the object (e.g., top view, front
view, back view, side view and etc).
• So requires projection transformation.
156By: Tekendra Nath Yogi2/9/2019
Contd…
• Viewing pipeline:
157By: Tekendra Nath Yogi2/9/2019
Fig: General 3D transformation pipeline, from modeling coordinates to final device coordinates
Contd…
• Construct the shape of individual objects in a scene within
modeling coordinate, and place the objects into appropriate
positions within the scene (world coordinate).
158By: Tekendra Nath Yogi2/9/2019
Contd…
• World coordinate positions are converted to viewing
coordinates
159By: Tekendra Nath Yogi2/9/2019
Contd…
• Convert the viewing coordinate description of the scene to
coordinate positions on the projection plane.
160By: Tekendra Nath Yogi2/9/2019
Contd…
• Positions on the projection plane, will then mapped to the
Normalized coordinate and output device.
161By: Tekendra Nath Yogi2/9/2019
Projection
Presented by: Tekendra Nath Yogi
Tekendranath@gmail.com
College of applied business and technology
2/9/2019 162By: Tekendra Nath Yogi
Projections
• In general, projection transform points in a coordinate system of dimension n
into points in a coordinate system of dimension less than n.
• Projection is the mapping or transformation of a three-dimensional (3D) object
into a two-dimensional (2D) object.
2/9/2019 163By: Tekendra Nath Yogi
Contd…
• How projections are constructed?
– projections are constructed by linearly mapping points in 3D space
to points on a 2D projection plane.
– The projected point on the plane is chosen such that it
is collinear with the corresponding 3D point and the centre of
projection.
– The lines connecting these points are referred to as projectors.
– The centre of projection is the location of the observer
– The plane of projection (view plane)is the surface on which the 2D
projected image of the scene is recorded/viewed.
2/9/2019 164By: Tekendra Nath Yogi
Contd…
• Properties of projection:
– Projections map points from one space to another coordinate
space of lower dimension, and hence involves loss of
information.
– Projections are not invertible.
– All points on a projector map to the same point on the plane
of projection.
2/9/2019 165By: Tekendra Nath Yogi
Types of projection
• Projections are of the following types:
2/9/2019 166By: Tekendra Nath Yogi
Contd..
• Parallel Projection:
– A parallel projection is a projection of an object in three-
dimensional space onto a projection plane(2D), where the projection
lines are parallel to each other.
2/9/2019 167By: Tekendra Nath Yogi
Contd…
• How ?
– Parallel projection discards z-coordinate and parallel lines from each vertex
on the object are extended until they intersect the view plane.
– The point of intersection is the projection of the vertex.
– we connect the projected vertices by line segments which correspond to
connections on the original object.
• A parallel projection preserves relative proportion of objects, but
dose not give us a realistic representation of the appearance of
object.
2/9/2019 168By: Tekendra Nath Yogi
Contd…
• Various types of parallel projections are :
2/9/2019 169By: Tekendra Nath Yogi
Contd…
• Oblique projection:
– The projectors in oblique projection intersect the projection plane at an
oblique angle( not perpendicular) to produce the projected image.
2/9/2019 170By: Tekendra Nath Yogi
Contd…
• Orthographic Projection:
– Orthographic projection used to produce the front, side, and
top views of an object.
– Projectors are perpendicular to the projection plane.
2/9/2019 171By: Tekendra Nath Yogi
Contd…
• Perspective Projection:
– In this projection projectors all converge at a single point
called center of projection or projection reference point.
2/9/2019 172By: Tekendra Nath Yogi
Contd…
• How?
– The object positions are transformed to the view plane along converged
projectors and the projected view of an object is determined by calculating
the intersection of the converged projectors with the view plane as shown in
figure.
2/9/2019 173By: Tekendra Nath Yogi
Contd…
• Advantages and Disadvantages of perspective projection:
– Objects further from viewer are projected smaller than the same sized
objects closer to the viewer.
• Looks realistic
– Equal distances along lines are not projected into equal distances (non-
uniform foreshortening)
– Angles preserved only in planes parallel to the projection plane
– More difficult to construct by hand than parallel projections (but not
more difficult by computer)
2/9/2019 174By: Tekendra Nath Yogi
Comparison between Parallel and Perspective
• Parallel Projections:
– The center of projection
is at infinity.
– The projectors are parallel
to each other.
• Perspective Projections:
– The center of projection is
a finite point.
– The projectors intersect at
the center of projection.
2/9/2019 175By: Tekendra Nath Yogi
Contd…
• Types of perspective projection:
2/9/2019 176By: Tekendra Nath Yogi
Assignment!
Homework
1. What is projection? Differentiate between parallel and perspective projection.
2. What is perspective projection? Explain the different types of perspective
projection.
3. Write a procedure to perform a two-point perspective projection of an object.
2/9/2019 177By: Tekendra Nath Yogi
Thank You !
178By: Tekendra Nath Yogi2/9/2019

B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi

  • 1.
    Unit 2 Presented By: Tekendra Nath Yogi Tekendranath@gmail.com College Of Applied Business And Technology 2/9/2019 1By: Tekendra Nath Yogi
  • 2.
    Outline • Geometrical Transformations •2D Transformations: – Basic transformations :Translation, rotation and scaling • Matrix Representations and Homogeneous Coordinates • Composite Transformations : – Two successive Translations ,Rotations, Scaling – General Pivot-Point Rotation – General Fixed-Point Scaling • Other 2D transformations : reflection, shear • Two-dimensional viewing: – Window to View Port Transformation. • 3D Transformations: – Basic transformations :Translation, rotation and scaling – Other transformations: reflection, shear • 3D Viewing • Projections 2By: Tekendra Nath Yogi2/9/2019
  • 3.
    Geometric Transformation • Geometrictransformation is the process of altering the coordinate description of objects. • Purposes: – To move the position of objects – To alter the shape / size of objects – To change the orientation of objects • Types: – Rigid Body Transformation( Transformation without deformation of shape) – Non Rigid Body Transformation( Transformation with change in shape) 3By: Tekendra Nath Yogi2/9/2019
  • 4.
    Contd…. • Basic 2-Dtransformations: – Translation – Rotation – Scaling 4By: Tekendra Nath Yogi2/9/2019
  • 5.
    Contd…. • Two-Dimensional translation: –One of rigid-body transformation, which move objects without deformation. – Translate an object by Adding translation distances to coordinates to generate new coordinates positions – Let,(x, y) be the 2-D point and tx, ty be the translation distance, we have – In matrix format, where T is the translation vector 5By: Tekendra Nath Yogi2/9/2019 xtx'x  yty'y         y x P        y x t t T       'y 'x 'P TP'P  Translating a point from position P to position P' with translation vector T.
  • 6.
    Contd…. • Example1: Translatethe given point (2,5) by translation vector (3,3) 6By: Tekendra Nath Yogi2/9/2019
  • 7.
    Contd…. • Example2: Translatea polygon with coordinates A(2,5), B(7,10) and C(10,2) by 3 units in x direction and 4 unit in y direction. • Solution: 7By: Tekendra Nath Yogi2/9/2019 Translated by T(3,4) Fig: Before translation Fig: After translation
  • 8.
    Contd…. • Homework: Translatethe triangle with vertices A(2,4), B(1,7) and C(4,6) by translation vector T(2,4). 8By: Tekendra Nath Yogi2/9/2019
  • 9.
    Contd…. • 2-D Rotation: 9By:Tekendra Nath Yogi2/9/2019
  • 10.
    Contd…. • Rotation ofpoint position (x, y) when the pivot point (xr, yr) is at coordinate origin(for positive value of rotation angle): 10By: Tekendra Nath Yogi2/9/2019
  • 11.
    Contd…. • The originalcoordinates of the point in polar coordinates are: • Transformed coordinates: • In matrix form: OR Where, R is a rotation matrix and is given as: 11By: Tekendra Nath Yogi2/9/2019 cosrx  sinyy    cossinsinsinsincos)sin(' sincossinsincoscos)cos(' yxrrry yxrrrx             cossin sincos R PR'P 
  • 12.
    Contd…. • When coordinatepositions are represented as row vectors instead of column vectors the transformed point (x’, y’ ) is calculated as: • i.e., 12By: Tekendra Nath Yogi2/9/2019
  • 13.
    Contd…. • For negativevalue of rotation angle: 13By: Tekendra Nath Yogi2/9/2019
  • 14.
    Contd…. • Example: Apoint (4,3) is rotated counterclockwise by an angle 45 degree. Find the rotation matrix and the resultant point. • Solution: 14By: Tekendra Nath Yogi2/9/2019
  • 15.
    Contd…. • Homework: – Example2:Rotate the triangle ABC having coordinates A(1,2), B(2,3) and C(4,5) by 60⁰ about the origin. – Example3: A point (4,3) is rotated clockwise by an angle -45 degree. Find the rotation matrix and the resultant point. – Example4: Rotate the triangle with vertices A(5,8), B(12,10) and C(10,10) about origin with angle 90 degree in anticlockwise direction. 15By: Tekendra Nath Yogi2/9/2019
  • 16.
    Contd…. • 2-D scalingTransformation: – alters the size of an object. – carried out for polygons by multiplying the coordinate values (x, y) of each vertex by scaling factors sx and sy to produce the transformed coordinates (x', y'): – scaling factors sx scales object in the x-direction and scaling factor sy scales object in the y-direction. – In matrix form: 16By: Tekendra Nath Yogi2/9/2019 xsx'x  ysyy                    y x s0 0s 'y 'x y x PS'P 
  • 17.
    Contd…. • Example1: scalethe polygon with coordinates A(2,5), B(7,10) and C(10,2) by two units in x-direction and two units in y- direction. 17By: Tekendra Nath Yogi2/9/2019
  • 18.
  • 19.
    Homework • Example2: performthe scaling transformation to the triangle with vertices A(6,9), B(10,5) and C(4,3) with scaling factors sx=3 and sy=2. • Example3:scale the rectangle ABCD with vertices A(2,2) , B(2,6), C(5,2) ad D(5,6) to double its size. • Example4: perform the scaling transformation to the triangle with vertices A(6,10), B(10,6) and C(4,2) with scaling factors sx=0.5 and sy=0.5. 19By: Tekendra Nath Yogi2/9/2019
  • 20.
    Matrix Representations andHomogeneous coordinates • Many graphics applications involve sequences of geometric transformations – E.g., In design and picture construction applications, we perform translations, rotations, and scaling to fit the picture components into their proper positions. • But this sequential transformation process is not efficient. • Solution: Use homogeneous coordinate system! 20By: Tekendra Nath Yogi2/9/2019
  • 21.
    Contd…. •What is homogeneouscoordinates? – A point (x, y) can be re-written in homogeneous coordinates as (xh, yh, h) – The homogeneous parameter h is a non- zero value such that: – We can then write any point (x, y) as (h*x, h*y, h) – We can conveniently choose h = 1 so that (x, y) becomes (x, y, 1) 21By: Tekendra Nath Yogi2/9/2019 h x x h  h y y h 
  • 22.
    Contd…. • Homogeneous coordinatesystem allows us to express transformation equations as matrix multiplication. • The homogeneous coordinates allow combined transformation, eliminating the calculation of intermediate coordinate values and thus save required time for transformation and memory required to store the intermediate coordinate values. 22By: Tekendra Nath Yogi2/9/2019
  • 23.
    Contd…. • Homogeneous coordinatefor translation: • Alternatively, 23By: Tekendra Nath Yogi2/9/2019                                1100 10 01 1 ' ' y x t t y x y x
  • 24.
    Contd…. • Homogeneous coordinatesfor Rotation: • Alternatively, 24By: Tekendra Nath Yogi2/9/2019                                 1100 0cossin 0sincos 1 ' ' y x y x  
  • 25.
    Contd…. • Homogeneous coordinatesfor scaling • Alternatively, 25By: Tekendra Nath Yogi2/9/2019                                1100 00 00 1 ' ' y x s s y x y x
  • 26.
    Inverse transformations: • Inversetranslation: – The inverse translation matrix can be obtained by replacing the translation distances tx and ty with their negatives: -tx and –ty. – i.e., – So, 26By: Tekendra Nath Yogi2/9/2019              100 t10 t01 T y x 1                                  1100 10 01 1 ' ' y x t t y x y x
  • 27.
    Contd…. • Inverse Rotation: •The inverse rotation matrix can be obtained by replacing the rotation angle with its negative value. • i.e., • So, 27By: Tekendra Nath Yogi2/9/2019            100 0cossin 0sincos R 1                                  1100 0cossin 0sincos 1 ' ' y x y x  
  • 28.
    Contd…. • Inverse scaling: –Inverse scaling matrix can be obtained by replacing sx and sy by 1/sx and 1/sy respectively. – i.e., – So, 28By: Tekendra Nath Yogi2/9/2019                  100 0 1 0 00 1 1 sy s S x                                1100 0/10 00/1 1 ' ' y x s s y x y x
  • 29.
    Composite transformations • Thebasic purpose of composite transformations is to gain efficiency by applying a single composed transformation to a point, rather than applying a series of transformations, one after the other. 29By: Tekendra Nath Yogi2/9/2019
  • 30.
    Contd… • Two successiveTranslations: – If two successive translation distances (tx1, ty1) and (tx2, ty2) are applied to coordinate position P, the final transformed location P’ is calculated as: – The composite transformation matrix for this sequence of translation is: – Or – Which demonstrates that two successive translations are additive. 30By: Tekendra Nath Yogi2/9/2019 PttTttT PttTttTP yxyx yxyx )}.,().,({ }).,().{,(' 1122 1122                                    100 10 01 100 10 01 . 100 10 01 21 21 1 1 2 2 yy xx y x y x tt tt t t t t ),(),().,( 21211122 yyxxyxyx ttttTttTttT 
  • 31.
    Contd… • Two successiverotations: – For Successive Rotations θ1 and θ2 – Successive Rotations are additive. i.e., – Now proving this statement: 31By: Tekendra Nath Yogi2/9/2019 PRR PRRP )}.().({ }).().{(' 12 12     )()().( 2112   RRR
  • 32.
    Contd… • Which demonstratesthat two successive rotations are additive. • So the final rotated coordinates can be calculated with the composite rotation matrix as: 32By: Tekendra Nath Yogi2/9/2019 PRP ).(' 21  
  • 33.
    Contd… • Two successivescaling: – Successive Scaling are multiplicative – Or, 33By: Tekendra Nath Yogi2/9/2019                                100 0.0 00. 100 00 00 . 100 00 00 21 21 1 1 2 2 yy xx y x y x ss ss s s s s ).,.(),().,( 21211122 yyxxyxyx ssssSssSssS 
  • 34.
    Contd… • General PivotRotation: can generate rotations about an arbitrary point (xr, yr) by performing the following sequence of translate-rotate-translate operations: – Translate the object so that the pivot-point position is moved to the coordinate origin. – Rotate the object about the coordinate origin. – Translate the object so that the pivot point is returned to its original position. 34By: Tekendra Nath Yogi2/9/2019
  • 35.
    Contd… • This transformationsequence is illustrated in the following fig: 35By: Tekendra Nath Yogi2/9/2019
  • 36.
  • 37.
    Contd… • Example: Rotatethe triangle having coordinates (1,2),(2,3) and (4,5) by 60⁰ about (2,3). • Example: perform the counterclockwise 45O rotate of triangle A(2,3), B(5,5), C(4,3) about point (3,4). 37By: Tekendra Nath Yogi2/9/2019
  • 38.
    Contd… • General fixedpoint scaling: – Translate object so that the fixed point coincides with the coordinate origin. – Scale the object with respect to the coordinate origin. – Use the inverse translation of step 1 to return the object to its original position. 38By: Tekendra Nath Yogi2/9/2019
  • 39.
    Contd… • The abovetransformation sequence to achieve fixed point scaling is illustrated in the following fig: 39By: Tekendra Nath Yogi2/9/2019
  • 40.
    Homework • Example: Findthe transformation matrix that transforms the given square ABCD to half its size about (2,2,). The coordinates of the square are A(1,1), B(3,1), C(3,3) and D(1,3). 40By: Tekendra Nath Yogi2/9/2019
  • 41.
    Homework • Example: Rotate∆ABC by 45⁰ clockwise about the origin and scale it by (2,3) about the origin. • Example: Rotate ∆ABC by 90⁰ anti-clockwise about the (5,8) and scale it by (2,2) about (10,10). 41By: Tekendra Nath Yogi2/9/2019
  • 42.
    Other 2-D Transformations •Reflection • Shear 42By: Tekendra Nath Yogi2/9/2019
  • 43.
    Reflection • A reflectionis a transformation that produces a mirror image of an object. • The mirror image for a two-dimensional reflection is generated relative to an axis of reflection by rotating the object 180 degree about the reflection axis. 43By: Tekendra Nath Yogi2/9/2019
  • 44.
    Contd… • Reflection aboutx-axis: – Also known as reflection about line y=0 – Change the sign of y coordinate but x-coordinate remains same • X’= X • Y’=- Y – In matrix form – Equivalent to 180O rotation about x-axis 44By: Tekendra Nath Yogi2/9/2019
  • 45.
    Contd… • Reflection abouty-axis: – Also known as reflection about line x=0. • Change the sign of x-coordinate but y-coordinate remains same • X’= -X • Y’= Y – In matrix form: – Equivalent to 180O rotation about y-axis 45By: Tekendra Nath Yogi2/9/2019
  • 46.
    Contd… • Reflection aboutorigin: – Also known as reflection about axis that is perpendicular to xy-plane and that passes through the coordinate origin. – Change the sign of both x-coordinate and y-coordinate. » x’=-x » y’=-y – In matrix form: – Equivalent to 180O rotation about origin 46By: Tekendra Nath Yogi2/9/2019
  • 47.
    Contd… • Reflection aboutarbitrary fixed point: – same as a 180o rotation in the xy plane using the reflection point as the pivot point. 47By: Tekendra Nath Yogi2/9/2019
  • 48.
    Contd… • Reflection abouta diagonal line y=x: can be obtained by performing following sequence of transformations: – Clock wise Rotation with 450 – reflection with x-axis – Inverse rotation with 450 48By: Tekendra Nath Yogi2/9/2019           100 001 010
  • 49.
    Contd… 49By: Tekendra NathYogi2/9/2019 1. first perform a clockwise rotation through a 45" angle 2.Next, we perform a reflection with respect to the x axis. 3. back to its original position with a counterclockwise rotation through 45".
  • 50.
    Contd… • Reflection abouta diagonal line y=-x: – Can be obtained by performing the following sequence of transformations: • clockwise rotation • reflection about the y axis, and • counterclockwise rotation . 50By: Tekendra Nath Yogi2/9/2019             100 001 010
  • 51.
    Contd… • Reflections aboutany line y = mx+ c in the xy plane: – can be accomplished with a combination of : 1. translate the Line so that it passes through the origin i.e., T(0, -c) 2. rotate the line onto one of the coordinate axes and reflect about that axis. i.e., 1. R(-theta) 2. Reflection with coordinate axis-axis 3. restore the line to its original position with the inverse rotation and translation transformations i.e., 1. R(theta) 2. T(0.c) 51By: Tekendra Nath Yogi2/9/2019
  • 52.
    Contd… • Example: Findout final transformation matrix, when point p(x, y) is to be reflected about a line y= mx+c. • Solution: 52By: Tekendra Nath Yogi2/9/2019
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
    Contd… • Question: Determinethe transformation for reflection about y=x+3 57By: Tekendra Nath Yogi2/9/2019
  • 58.
    Contd… • Question: Translatethe given triangle A(1,3), B(-2,-1) and C(6,-2) with translation vector T(-2,-6) and then reflect about y=x axis. 58By: Tekendra Nath Yogi2/9/2019
  • 59.
    Shearing 59By: Tekendra NathYogi A transformation that distorts the shape of an object. 2/9/2019
  • 60.
  • 61.
    Homework 1. Scale therectangle ABCD with vertices A(2,2),B(2,6), C(5,2) and D(5,6) to double its size about fixed point (2,3) then translate it using translation vector (1,3). 2. Rotate the triangle ABC with vertices A(3,5), B(7,2) and C(4,9) in counterclockwise direction by 90 degree and then enlarge it to double its size. 3. A unit square is located at origin shear it along horizontal direction with shearing coefficient 2. 4. Find out the final coordinates of a figure bounded by the coordinate (1,1), (3,4), (5,7), (10,3) when rotated about a point (8,8) by 30 degree in clockwise direction and scaled by two units in x-direction and three units y-direction. 5. Show that 2D reflection through x-axis followed by 2-D reflection through the line y=- x is equivalent to a pure rotation about the origin. 6. Show that transformation matrix for reflection about a line y=x is equivalent to reflection to x-axis followed by counter clockwise rotation of 90degree. 7. Reflect rectangle PQRS, P(1,2), Q(1,6), R(9,6) and S(9,2) on y=5 axis, then scale about (2,3) with scale factor (4,2) and finally rotate with rotation angle +45o about origin. Use homogenous coordinate system to calculate transformed rectangle coordinates. 61By: Tekendra Nath Yogi2/9/2019
  • 62.
    3D Transformations Presented By: Tekendra Nath Yogi Tekendranath@gmail.com College Of Applied Business And Technology 2/9/2019 62By: Tekendra Nath Yogi
  • 63.
    3D Transformations • Extendfrom two-dimensional transformation by including considerations for the z coordinates. • Translation and scaling are similar to two-dimension, include the three Cartesian coordinates • Rotation method is less straight forward • The most common 3D transformations are: – Translation – Rotation – Scaling – Reflection and – shears 63By: Tekendra Nath Yogi2/9/2019
  • 64.
    Contd… • Three-dimensional translation: •A point P (x, y, z) in three-dimensional space translate to new location p’(x’, y’, z’) with the translation distance T (tx, ty, tz) as : • In matrix form: 64By: Tekendra Nath Yogi2/9/2019 xtx'x  yty'y                                        11000 100 010 001 1 ' ' ' z y x t t t z y x z y x PT'P  ztz'z 
  • 65.
    Contd… • Questions: Translatethe 3D square with vertices A(4,5,7), B(- 3,-2,1) , C(2,4,7) and D(-5,3,2) using translation vector (1,3,4). 65By: Tekendra Nath Yogi2/9/2019
  • 66.
    Contd… • Three-dimensional scaling: –Relative to the coordinate origin, just include the parameter for z coordinate scaling in the transformation matrix – Relative to a fixed point (xf, yf zf) • Perform a translate-scaling-translate composite transformation 66By: Tekendra Nath Yogi2/9/2019                  1000 )1(00 )1(00 )1(00 ),,(),,(),,( fzz fyy fxx fffzyxfff zss yss xss zyxTsssSzyxT PS'P                                        1 z y x 1000 0s00 00s0 000s 1 'z 'y 'x z y x
  • 67.
    Contd… • The sequenceof transformations for fixed point scaling is demonstrated in Fig below. 67By: Tekendra Nath Yogi2/9/2019
  • 68.
    Contd… • Question1: A3D object with vertices A(-2,-4,4), B(3,-6, -8), C(- 6,1,0) and D(3.-6.2) is required to scale with scale factor S(2,4,6) about origin. Find the final coordinates. • Question2: Given a solid PQT , p( 2,-5,0), Q(4,-2,3) and T(6,-7,-1) is translated with T(9,0,-2) and then scale about origin with scaling factor (2,4,5). Find the final coordinates. • Question3: suppose we have a quadrilateral ABCD with vertices A(3,1,4), B(-7,-4,2) C(5, -8, -3) and D(3,0,1). What is the coordinates of quadrilateral if it is to be doubled in size about origin. Then translate obtained coordinates with (-4,3,1) • Question 4: scale the triangle with vertices A(-3,-2,1), B(4,5,6), C(5,7,9) to double its size about fixed point (1,2,3). 68By: Tekendra Nath Yogi2/9/2019
  • 69.
    3D Rotation • Togenerate a rotation transformation for an object, we must designate an axis of rotation (about which the object is to be rotated) and the amount of angular rotation. • Axis of rotation can be: – Coordinate axis – Parallel axis, or – Arbitrary axis. • Angle of rotation( ) can be: – Positive : indicate counter clock wise rotation, or – Negative: indicate the clock wise rotation. 69By: Tekendra Nath Yogi2/9/2019
  • 70.
    Coordinate-Axes Rotations: • A)Rotation about Z-axis 70By: Tekendra Nath Yogi2/9/2019
  • 71.
    Contd.. • Any pointp(x, y, z) can be rotated about z-axis with angle as follows: • In matrix form: 71By: Tekendra Nath Yogi                                        1 z y x 1000 0100 00cossin 00sincos 1 'z 'y 'x   zz yxy yxx    ' cossin' sincos'   PRP z ).('                 1000 0100 00cossin 00sincos )(   zR 2/9/2019
  • 72.
    Contd.. • B) RotationAbout X-axis 72By: Tekendra Nath Yogi2/9/2019
  • 73.
    Contd.. • Any pointp(x, y, z) can be rotated about x-axis with angle as follows: • In matrix form: 73By: Tekendra Nath Yogi                 1000 0cossin0 0sincos0 0001   xx RR x'x coszsiny'z sinzcosy'y                                            1 . 1000 0cossin0 0sincos0 0001 1 ' ' ' z y x z y x   PRP x ).('   2/9/2019
  • 74.
    Contd.. • C) RotationAbout Y-axis 74By: Tekendra Nath Yogi2/9/2019
  • 75.
    Contd.. • Any pointp(x, y, z) can be rotated about y-axis with angle as follows: • In matrix form: 75By: Tekendra Nath Yogi y'y cosxsinz'x sinxcosz'z                      1000 0cos0sin 0010 0sin0cos   yy RR                                       1 . 1000 0cos0sin 0010 0sin0cos 1 ' ' ' z y x z y x   PRP y ).('   2/9/2019
  • 76.
    Contd… • Question1: Acoordinate point p(3,2,1) is translated in x, y and z direction by -2, -2 and -2 unit respectively followed by rotation with 60o about x- axis. Find the final position of a point • Question 2: A cube of length 10 units having one of its corner at origin (0, 0, 0) and three edges along three principle axis. If the cube is to be rotated about z-axis by an angle of 45 degree in counterclockwise direction, then calculate the new position of the cube. • Question 3: The pyramid defined by the coordinates A(0,0,0) B(1,0,0), C(0,1,0) and D(0,0,1) is scaled to double its size about point (0,1,0), then translated to new position by translation vector (4,5,6) and rotated by angle 45 degree in clockwise direction about origin. Use homogeneous transformation matrix to find the new vertices of pyramid. 76By: Tekendra Nath Yogi2/9/2019
  • 77.
    Contd.. • Rotation aboutaxis parallel to coordinate axis – when an object is to be rotated about an axis that is parallel to one of the coordinate axes, we can attain the desired rotation with the following transformation sequence. • Translate the object so that the rotation axis coincides with the parallel coordinate axis. • Perform the specified rotation about that axis. • Translate the object so that the rotation axis is moved back to its original position. 77By: Tekendra Nath Yogi2/9/2019
  • 78.
    Contd.. • The sequenceof transformations for rotation about axis parallel to coordinate axis(e.g.., x-axis) is demonstrated in figure below: step1 step2 step3 78By: Tekendra Nath Yogi2/9/2019
  • 79.
    Contd.. • Rotation aboutarbitrary axis that is not parallel to one of the coordinate axes : – when an object is to be rotated about an axis that is not parallel to one of the coordinate axes, we can attain the desired rotation with the following transformation sequence. 79By: Tekendra Nath Yogi2/9/2019
  • 80.
    Contd.. – Translate theobject so that the rotation axis passes through the coordinate origin. – Rotate the object so that the axis of rotation coincides with one of the coordinate axes. – perform the specified rotation about that coordinate axis. – Apply inverse rotation to bring the rotation axis back to its original orientation. – Apply the inverse translation to bring the rotation axis back to its original position. 80By: Tekendra Nath Yogi2/9/2019
  • 81.
    Contd.. 81By: Tekendra NathYogi Fig: Five transformation steps for obtaining a composite matrix for rotation about arbitrary axis, with the rotation axis projected onto the z-axis2/9/2019
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
    Contd… • Example: Findthe new co-ordinates of a unit cube 90 degree rotated about an axis defined by its end points A(2,1,0) and B(3,3,1). 87By: Tekendra Nath Yogi2/9/2019 A unit cube
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
    Contd… • Question1: Rotatetriangle with vertices A(), B(0,2,1),(2,3,0) and (1,2,1) about the line joining the point (0,0,0) and (1,1,1) with the angle of rotation 450 in counter clockwise direction. • Question1: Rotate triangle with vertices A(0,2,1),B(2,3,0) and C(1,2,1) about the line joining the point (2,2,2) and (1,1,1) with the angle of rotation 450 in counter clockwise direction. 94By: Tekendra Nath Yogi2/9/2019
  • 95.
    Reflections • A three-dimensionalreflection can be performed relative to a selected reflection axis or with respect to a selected refection plane. • Reflections relative to a given axis are equivalent to 18o0 rotations about that axis. • Reflections with respect to a plane are equivalent to 1800 rotations in four-dimensional space. • Reflection plane can be a coordinate plane (either xy, xz, or yz) 95By: Tekendra Nath Yogi2/9/2019
  • 96.
    Contd… • Reflection inxy plane: • This transformation changes the sign of the z coordinates, Leaving the x and y-coordinate values unchanged. – x’ = x – y’ = y – z’ = -z • The matrix representation for this reflection of points relative to the x-y plane is: 96By: Tekendra Nath Yogi2/9/2019
  • 97.
    Contd… • Reflection inyz plane: – This transformation changes the sign of the x coordinates, Leaving the z and y-coordinate values unchanged. • x’ = -x – y’=y – z’=z – The matrix representation for this reflection of points relative to the x-y plane is: 97By: Tekendra Nath Yogi2/9/2019
  • 98.
    Contd… Reflection in XZplane: – This transformation changes the sign of the y coordinates, Leaving the z and x-coordinate values unchanged. – y’= -y – x’=x – z’=z – The matrix representation for this reflection of points relative to the x-y plane is: 98By: Tekendra Nath Yogi2/9/2019
  • 99.
    Shears • Shearing transformationsproduce distortions in the shapes of objects. • The transformation equations for a Z-axis shear is : – x’ = x + a.z – y’ = y + b.z – z’ = z The matrix representation for a z-axis shear is: 99By: Tekendra Nath Yogi                                      1 . 1000 0100 010 001 1 ' ' ' z y x b a z y x 2/9/2019
  • 100.
    Contd… • Similarly, Thematrix representation for a x-axis shear is: • The matrix representation for a y-axis shear is: 100By: Tekendra Nath Yogi2/9/2019                                      1 . 1000 010 001 0001 1 ' ' ' z y x b a z y x                                      1 . 1000 010 0010 001 1 ' ' ' z y x b a z y x
  • 101.
    Contd… • Question1: shearthe triangle with vertices A(1,2,1), B(5,4,7) and C(3,6,9) about x-axis using shearing coefficient shy=3 and shz=5. 101By: Tekendra Nath Yogi2/9/2019
  • 102.
    2D viewing • Picturesare stored in memory using Cartesian coordinate system referred to as world coordinate system. • But, pictures are displayed in display device using physical device coordinate system. • So, to display picture requires the transformation from world coordinate to device coordinate. • This mapping of coordinate can be achieved with the use of viewing transformation. 102By: Tekendra Nath Yogi2/9/2019
  • 103.
    Contd… • window : –A world-coordinate area selected for display is called a window. – defines what is to be viewed • viewport : – An area on a display device to which a window is mapped is called a viewport. – defines where it is to be displayed. 103By: Tekendra Nath Yogi2/9/2019
  • 104.
    Contd.. • viewing transformation: –The mapping of a part of a world-coordinate scene to device coordinates is referred to as a viewing transformation. – 2D viewing transformation referred to as the window-to-viewport transformation or the windowing transformation. 104By: Tekendra Nath Yogi2/9/2019 Fig: A viewing transformation using standard rectangles for the window and viewport.
  • 105.
    Contd… • viewing pipeline: –Takes the object coordinates through several intermediate coordinates systems before finishing with device coordinates as shown in figure below: 105By: Tekendra Nath Yogi2/9/2019 Fig: The 2D viewing-transformation pipeline
  • 106.
    Window to ViewportTransformation • A point at position (xw, yw) in a designated window is mapped to viewport coordinates (xv, yv) so that relative positions in the two areas are the same. • i.e., If a coordinate position is at the center of the viewing window, for instance, it will be displayed at the center of the viewport. 106By: Tekendra Nath Yogi2/9/2019
  • 107.
    Contd… • To maintainthe same relative placement, the following ratios must be equal. 107By: Tekendra Nath Yogi2/9/2019 minmax min minmax min minmax min minmax min ywyw ywyw yvyv yvyv xwxw xwxw xvxv xvxv          
  • 108.
    Contd… • By solvingthese equations for the unknown viewport position (xv, yv): • Where the scaling factors are: 108By: Tekendra Nath Yogi2/9/2019 syywywyvyv sxxwxwxvxv )( )( m inm in m inm in   m inm ax m inm ax m inm ax m inm ax ywyw yvyv xwxw xvxv sy sx      
  • 109.
    Contd… • Given awindow and viewport, what is the transformation matrix that maps the window from world coordinates into the viewport in screen coordinates? • This matrix can be developed by three step transformation composition as: – The object together with its widow is translated until the lower left corner of the window is at the origin. – Object and window are scaled until the window has the dimension of the viewport. – Translate the viewport to its correct position on the screen. 109By: Tekendra Nath Yogi2/9/2019
  • 110.
    Contd… • Above threesteps are illustrated in the following figure: 110By: Tekendra Nath Yogi2/9/2019 step0. Step 3.step2. step1.
  • 111.
    Contd… • Step1: translation 111By:Tekendra Nath Yogi2/9/2019              100 10 01 min min w W Y X T
  • 112.
    Contd… • Step2: scalingabout origin • Where, 112By: Tekendra Nath Yogi2/9/2019 minmax minmax minmax minmax ywyw yvyv xwxw xvxv sy sx                  100 00 00 y x s s S
  • 113.
    Contd… • Step 3:inverse translation 113By: Tekendra Nath Yogi2/9/2019            100 10 01 )( min min v v Y X Tinverse
  • 114.
    Contd… • The overalltransformation matrix for window to viewport transformation is: 114By: Tekendra Nath Yogi2/9/2019              100 ).(0 ).(0 minmin minmin syywyvs sxxwxvs y x             100 10 01 min min w W Y X           100 00 00 y x s s            100 10 01 min min v v Y X
  • 115.
  • 116.
    Contd… • Step2: calculatingthe scaling factor and then scaling transformation matrix • Sx=(1-0.5)/(20-10)=0.5/10= 0.05 • Sy=(1-0.5)/(20-10)= 0.5/10= 0.05 116By: Tekendra Nath Yogi2/9/2019
  • 117.
    Contd… • Step3: Inversetranslation matrix to maintain the relative position in view port is: 117By: Tekendra Nath Yogi2/9/2019
  • 118.
    Contd… • So, thefinal composite view transformation matrix is: 118By: Tekendra Nath Yogi2/9/2019 0 0
  • 119.
    Contd… • Example1: Translatethe triangle with vertices A(10,10), B(20, 30), and C(15,20) from window to viewport where window is defined by xwmin=50, xwmax=100, ywmin=20 and ywmax=100 and viewport is defined as xvmin=20, xvmax=45, yvmin=40 and yvmax=80 • Example2: Translate the triangle with vertices A(2,2), B(3, 5), and C(5,8) from window to viewport where window is defined by xwmin=1, xwmax=6, ywmin=2 and ywmax=10 and viewport is defined as xvmin=0, xvmax=2 yvmin=0 and yvmax=4 • Example3: consider the window is located from 0 to 100 and a point is located in (30, 30). Identify the point position in the viewport located from 0 to 50. 119By: Tekendra Nath Yogi2/9/2019
  • 120.
    Clipping Presented by: TekendraNath Yogi Tekendranath@gmail.com College of applied business and technology 2/9/2019 120By: Tekendra Nath Yogi
  • 121.
    Clipping • Any procedurethat identifies those portions of a picture that are either inside or outside of a specified region of a space is referred to as clipping. • The region against which an object is to be clipped is called a clip window. Depending on the application a clip window can be polygon or curved boundaries. • World- coordinate clipping removes the primitives outside the window from further consideration; thus eliminating the processing necessary to transform these primitives to device space. • Clipping type- point ,line, polygon, curved areas and etc. 121By: Tekendra Nath Yogi2/9/2019
  • 122.
    Contd… • Applications ofclipping include: – Extracting part of a defined scene for viewing – Identifying visible surfaces in three-dimensional views – Antialiasing line segments or object boundaries – Creating objects using solid-modeling procedures – Displaying a multi-window environment – Drawing and painting operations that allow parts of a picture to be selected for copying, moving, erasing, or duplicating. 122By: Tekendra Nath Yogi2/9/2019
  • 123.
    Point Clipping • Ina rectangular clip window save a point P = (x, y) for display(i.e., not clipped) if the following inequalities are satisfied: • Xwmin ≤ x ≤ xwmax • ywmin ≤ y ≤ ywmax • If any one of these four inequalities is not satisfied, the point is clipped (not saved for display). • The equal sign indicates that point on the window boundary are included within the window. 123By: Tekendra Nath Yogi2/9/2019
  • 124.
  • 125.
    Line clipping • Thevisible segment of a straight line can be determined by inside – outside test: – A line with both endpoints inside clipping boundary, such as the line from p1 to p2, is saved. 125By: Tekendra Nath Yogi2/9/2019
  • 126.
    Contd… • A linewith both endpoints outside the clip boundary, such as the line from p3 to p4, is not saved. 126By: Tekendra Nath Yogi2/9/2019
  • 127.
    Contd… • If theline is not completely inside or completely outside (e.g., p7 to p8 ), then perform intersection calculations with one or more clipping boundaries. 127By: Tekendra Nath Yogi2/9/2019
  • 128.
    Cohen-Sutherland Line Clipping •This algorithm clips the line by performing following steps: • Step1: Region code assignment – divide the whole picture region into nine regions by extending the window boundaries as shown in figure below and then assign a 4-bit region code to each region as follows: 1001 1000 1010 0001 0000 Window 0010 0101 0100 0110 Rules For assigning region code: T=1 , if the region is above the window, = 0 , otherwise. B= 1, if the region is below the window, = 0, otherwise. R=1, if the region is right of window, = 0, otherwise. L= 1, if the region is left of window, = 0, otherwise. 128By: Tekendra Nath Yogi2/9/2019
  • 129.
    Contd… • Every end-pointis labelled with the appropriate region code • For example: wymax wymin wxmin wxmax Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110] 129By: Tekendra Nath Yogi2/9/2019
  • 130.
    Contd… • Step2: Trivialacceptance of line segment – Lines completely contained within the window boundaries have region code [0000] for both end-points so are not clipped. i.e., accept these lines trivially. – E.g., line p5p6 wymax wymin wxmin wxmax Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110] 130By: Tekendra Nath Yogi2/9/2019
  • 131.
    • Step3: Trivialrejection and clipping – 3.1 : Any lines that have a 1 in the same bit position in the region-codes for each endpoint are completely outside and we reject these lines. – The AND operation can efficiently check this: If the logical AND of both region codes result is not 0000, the line is completely outside the clipping region so clipped. Contd… wymax wymin wxmin wxmax Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110] 131By: Tekendra Nath Yogi2/9/2019
  • 132.
    3.2:If the logicalAND operation results in 0000 then a) Choose an endpoint of the line that is outside the window. b) Find the intersection point at the window boundary by using the following formula: c) Replace endpoint with the intersection point and update the region code. Above process is repeated until we find a clipped line either trivially accepted or trivially rejected. Contd… 132By: Tekendra Nath Yogi2/9/2019
  • 133.
  • 134.
    Contd.. • Example: Usethe Cohen-Sutherland line clipping algorithm to clip line defined with end points p1(0,120) and (130,5) against a window defined by the following four points : (10,10), (10,100), (150,10) and (150,100) 134By: Tekendra Nath Yogi2/9/2019
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
    • Example1: LetABCD be the rectangular window with A(20, 20), B(90, 120), C(90, 70), and D(20,70). Find the region codes for end points and use Cohen- Sutherland algorithm to clip the line p q with p( 10,30) and q(80, 90). • Example2: Use the Cohen-Sutherland algorithm to clip line defined with end points p1(40,15) and p2(75,45) against a window A(50,10), B(80,10), C(80,40) and D(50,40). • Example3: Use the Cohen-Sutherland algorithm to clip line defined with end points p1(70, 20) and p2(100,10) against a window A(50,10), B(80,10), C(80,40) and D(50,40). By: Tekendra Nath Yogi 139 Homework 2/9/2019
  • 140.
    Polygon Clipping • Polygonclipping algorithm generates one or more closed bounded areas as shown in figure below: By: Tekendra Nath Yogi 1402/9/2019
  • 141.
    Contd… • Sutherland-Hodgman PolygonClipping: – Begin with the initial set of polygon vertices, first clip the polygon against the left rectangle boundary to produce a new sequence of vertices. • The new set of vertices could be successively passed to a right boundary clipper, a bottom boundary clipper, and a top boundary clipper as shown in figure below. By: Tekendra Nath Yogi 1412/9/2019
  • 142.
    142 Contd… Left Clipper Right Clipper Bottom Clipper Top Clipper At eachstep, a new sequence of output vertices is generated and passed to the next window boundary clipper. 2/9/2019 By: Tekendra Nath Yogi
  • 143.
    As each pairof adjacent polygon vertices is passed to a next window boundary clipper, we make the following tests: 1. If the first vertex is outside the window boundary and the second vertex is inside Then , both the intersection point of the polygon edge with the window boundary and the second vertex are added to the output vertex list. For example: v1- outside and v2- inside Movement is out in Output vertex – intersection point v1’ and destination point v2 By: Tekendra Nath Yogi 1432/9/2019
  • 144.
    Contd… 2. If bothinput vertices are inside the window boundary. Then, only the second vertex is added to the output vertex list. • For example: – v1- inside – V2- inside – Movement in in – Output vertex = destination vertex – Therefore save V2 By: Tekendra Nath Yogi 1442/9/2019
  • 145.
    Contd… 3. If thefirst vertex is inside the window boundary and the second vertex is outside. Then, only the edge intersection with the window boundary is added to the output vertex list. • For Example: – V1-inside – V2- outside – Movement = in out – Therefore, save v1’ By: Tekendra Nath Yogi 1452/9/2019
  • 146.
    Contd…. 4. If bothinput vertices are outside the window boundary. Then, nothing is added to the output vertex list. • For Example: – V1- outside – V2- outside – Movement = out out – Therefore, save nothing By: Tekendra Nath Yogi 146 2/9/2019
  • 147.
    Contd… • Example1 :Weillustrate this algorithm by processing the area in figure against the left window boundary. • Vertices 1 and 2 are outside of the boundary. • Vertex 3, which is inside, 1' and vertex 3 are saved. • Vertex 4 and 5 are inside, and they also saved. • Vertex 6 is outside, 5' is saved. • Using the five saved points, we would repeat the process for the next window boundary. By: Tekendra Nath Yogi 1472/9/2019
  • 148.
    Contd… • Example2: clippolygon ABCDE against window PQRS. The coordinate of the polygon are A(80, 200), B(220, 120), C( 150, 100), D(100, 30), E(10, 120). Coordinates of the window are P(200,50), Q(50, 150), R(200, 150), S(50, 50). By: Tekendra Nath Yogi 1482/9/2019
  • 149.
    Homework • Example 3:You are provided with the clipping rectangle with co- ordinates A(10, 10), B(10, 20), C(20, 10) and D(20, 20). Clip the given polygon PQRS with coordinates P(5, 15), Q(15, 25), R(15, 15) and S(10, 10) using Sutherland - Hodgeman polygon clipping algorithm. By: Tekendra Nath Yogi 1492/9/2019
  • 150.
    Curve Clipping • Thebounding rectangle for a circle or other curved object can be used first to test for overlap with a rectangular clip window. • If the bounding rectangle for the object is completely inside the window, we save the object. • If the rectangle is determined to be completely outside the window, we discard the object. In either case, there is no further computation necessary. • But if the bounding rectangle test fails, we can look for other computation-saving approaches. 150By: Tekendra Nath Yogi2/9/2019
  • 151.
    Contd… • For acircle, we can use the coordinate extents of individual quadrants and then octants for preliminary testing before calculating curve-window intersections. • For an ellipse, we can test the coordinate extents of individual quadrants. 151By: Tekendra Nath Yogi2/9/2019
  • 152.
    Contd… • Figure belowillustrates circle clipping against a rectangular window. 152By: Tekendra Nath Yogi2/9/2019
  • 153.
    Contd… • Similar procedurescan be applied when clipping a curved object against a general polygon clip region. • On the first pass, we can clip the bounding rectangle of the object against the bounding rectangle of the clip region. • If the two regions overlap, we will need to solve the simultaneous line-curve equations to obtain the clipping intersection points. 153By: Tekendra Nath Yogi2/9/2019
  • 154.
    Homework 1. What isclipping? Explain the polygon clipping algorithm with suitable example. 2. Where do you require ellipse clipping algorithm? Explain in detail about ellipse clipping algorithm. 3. Why clipping is required in computer graphic? Explain the circle clipping algorithm. 2/9/2019 154By: Tekendra Nath Yogi
  • 155.
    3D viewing Presented by:Tekendra Nath Yogi Tekendranath@gmail.com College of applied business and technology 2/9/2019 155By: Tekendra Nath Yogi
  • 156.
    Introduction • 2D viewingtransfers position from the world coordinate plane to plane of the output device. • But in 3D viewing such direct transformation is not possible due to the different views of the object (e.g., top view, front view, back view, side view and etc). • So requires projection transformation. 156By: Tekendra Nath Yogi2/9/2019
  • 157.
    Contd… • Viewing pipeline: 157By:Tekendra Nath Yogi2/9/2019 Fig: General 3D transformation pipeline, from modeling coordinates to final device coordinates
  • 158.
    Contd… • Construct theshape of individual objects in a scene within modeling coordinate, and place the objects into appropriate positions within the scene (world coordinate). 158By: Tekendra Nath Yogi2/9/2019
  • 159.
    Contd… • World coordinatepositions are converted to viewing coordinates 159By: Tekendra Nath Yogi2/9/2019
  • 160.
    Contd… • Convert theviewing coordinate description of the scene to coordinate positions on the projection plane. 160By: Tekendra Nath Yogi2/9/2019
  • 161.
    Contd… • Positions onthe projection plane, will then mapped to the Normalized coordinate and output device. 161By: Tekendra Nath Yogi2/9/2019
  • 162.
    Projection Presented by: TekendraNath Yogi Tekendranath@gmail.com College of applied business and technology 2/9/2019 162By: Tekendra Nath Yogi
  • 163.
    Projections • In general,projection transform points in a coordinate system of dimension n into points in a coordinate system of dimension less than n. • Projection is the mapping or transformation of a three-dimensional (3D) object into a two-dimensional (2D) object. 2/9/2019 163By: Tekendra Nath Yogi
  • 164.
    Contd… • How projectionsare constructed? – projections are constructed by linearly mapping points in 3D space to points on a 2D projection plane. – The projected point on the plane is chosen such that it is collinear with the corresponding 3D point and the centre of projection. – The lines connecting these points are referred to as projectors. – The centre of projection is the location of the observer – The plane of projection (view plane)is the surface on which the 2D projected image of the scene is recorded/viewed. 2/9/2019 164By: Tekendra Nath Yogi
  • 165.
    Contd… • Properties ofprojection: – Projections map points from one space to another coordinate space of lower dimension, and hence involves loss of information. – Projections are not invertible. – All points on a projector map to the same point on the plane of projection. 2/9/2019 165By: Tekendra Nath Yogi
  • 166.
    Types of projection •Projections are of the following types: 2/9/2019 166By: Tekendra Nath Yogi
  • 167.
    Contd.. • Parallel Projection: –A parallel projection is a projection of an object in three- dimensional space onto a projection plane(2D), where the projection lines are parallel to each other. 2/9/2019 167By: Tekendra Nath Yogi
  • 168.
    Contd… • How ? –Parallel projection discards z-coordinate and parallel lines from each vertex on the object are extended until they intersect the view plane. – The point of intersection is the projection of the vertex. – we connect the projected vertices by line segments which correspond to connections on the original object. • A parallel projection preserves relative proportion of objects, but dose not give us a realistic representation of the appearance of object. 2/9/2019 168By: Tekendra Nath Yogi
  • 169.
    Contd… • Various typesof parallel projections are : 2/9/2019 169By: Tekendra Nath Yogi
  • 170.
    Contd… • Oblique projection: –The projectors in oblique projection intersect the projection plane at an oblique angle( not perpendicular) to produce the projected image. 2/9/2019 170By: Tekendra Nath Yogi
  • 171.
    Contd… • Orthographic Projection: –Orthographic projection used to produce the front, side, and top views of an object. – Projectors are perpendicular to the projection plane. 2/9/2019 171By: Tekendra Nath Yogi
  • 172.
    Contd… • Perspective Projection: –In this projection projectors all converge at a single point called center of projection or projection reference point. 2/9/2019 172By: Tekendra Nath Yogi
  • 173.
    Contd… • How? – Theobject positions are transformed to the view plane along converged projectors and the projected view of an object is determined by calculating the intersection of the converged projectors with the view plane as shown in figure. 2/9/2019 173By: Tekendra Nath Yogi
  • 174.
    Contd… • Advantages andDisadvantages of perspective projection: – Objects further from viewer are projected smaller than the same sized objects closer to the viewer. • Looks realistic – Equal distances along lines are not projected into equal distances (non- uniform foreshortening) – Angles preserved only in planes parallel to the projection plane – More difficult to construct by hand than parallel projections (but not more difficult by computer) 2/9/2019 174By: Tekendra Nath Yogi
  • 175.
    Comparison between Paralleland Perspective • Parallel Projections: – The center of projection is at infinity. – The projectors are parallel to each other. • Perspective Projections: – The center of projection is a finite point. – The projectors intersect at the center of projection. 2/9/2019 175By: Tekendra Nath Yogi
  • 176.
    Contd… • Types ofperspective projection: 2/9/2019 176By: Tekendra Nath Yogi Assignment!
  • 177.
    Homework 1. What isprojection? Differentiate between parallel and perspective projection. 2. What is perspective projection? Explain the different types of perspective projection. 3. Write a procedure to perform a two-point perspective projection of an object. 2/9/2019 177By: Tekendra Nath Yogi
  • 178.
    Thank You ! 178By:Tekendra Nath Yogi2/9/2019