0% found this document useful (0 votes)
330 views

CG Unit III Its A Notes Computer Graphics of Sppu

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

CG Unit III Its A Notes Computer Graphics of Sppu

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

lOMoARcPSD|44103007

CG Unit III - its a notes computer graphics of sppu

Computer Engineering (Savitribai Phule Pune University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007

r ., ,. . ....,ry,,,,.,,,--<~~,,.,.'11»"'.,.,,.,,,,.,.,,,,,,,.,,.,1
Unit · Ill f

6 2D Transformations

6.1 : Introduction

Q.1 Explain image transformation with example. .


l@r[SPPU : May-15, Marks 3]
Ans. : • Almost all graphics systems allow the programmer to define
picture that include a variety of transfonnations.
• For example, the programmer is able to magntfy a picture so that detail
appears more clearly, or reduce it so that more of the picture is visible. .
The programmer is also able to rotate the picture so· that he can see it in
different angles.

6.2 : Two - dimensional ·Transformations

Q.2 Scale the polygon with co-ordinates A (4,5), B (8,10) and C (8,2)
by 2 units in x-direction and 3 units in y-direction. Find the
transformed A, B and C points. ~[SP~U :_Dec.-14, ·Marks 6]
Ans. : ·

[~:1 = [: /o :1 [~ ~1
C' 8 2 1 0 0 1
= [,:
16 6
:1
1
The transfonned points are A~ = (8, 15), B' == (16, 30) and C' = (16, 6).
Q.3 Write 2D transformation matrices of translation, scaling. Give
the derivation of 2D rotation matrix. ..
~[SPPU : May-14, Dec.-14, Marks 4]

OR Describe w.r.t. 2D transformation :


i) Scaling ii) Rotation iii) Tra~slatlon
~[SPPU : Dec,-07,09,18, May-12,'15, Marks 8]

(6 - 1)

Downloaded by siddharth Patil (siddharthp718@gmail.com)


lOMoARcPSD|44103007

comp11terGrapl,lcs 6-3 2D Transformations


6. 2 2D Trans/ormat/ons
_________________ _
~Ca~,np~ui~u~Gr-,~~,.,~·cs'.._

Ans. : Translation : , Substituting equations (5) into (4), we g~t the transformation equations
• We can translate a two dimensional point for rotating a point (x, y) through an angle 8 about the origin as :
by adding translation_distances'. .~ an~ \ ., x' = x cos 8 - y sin 8 }
... (6)
to the original co--0rdinate pos1tto~. (x, Y) y' = x sin 8 + y cos 8
to move the point to a new position (x,
y), as sho'\\n in the Fig. Q.3.1 , The above equations can be represented in the matrix form as given
x= x+ ... (1) below
Fig: Q.3.1
y' = y + ty . . .. (2) [XI y '] = [
X y] [ COS 8
. sin 8]
-sm 8 cos 8
• The translation distance pair (~, \) is called a translation vector or
shift vector. P' = P,R ... (7)
• It is possi'ble to express the translationequations (1) and (2) as a single where R is rotation matrix and it is given as
matrix equation by using column vectors to represent co-ordinate R = [ cos 8 sin 8]
positions and the translationvector : -sin 8 · cos 8 · · · (&)

p =I
LL
X
.1 p' - ~] T - [:; l • It is important to note-that positive values for the rotation angle define
counterclockwiserotations · about the rotation point and negative values
rotate objects in the clockwise sense.
This allows us to write the two dimensional translation equations in the
matrix form : • For _negative values of 8 i.e. for clockwise rotation, the rotation matrix
P' = P + T ... (3) becomes
Rotation R [ cos(-0) sin(-8)]
• Let us consider the rotation of the y · --sin(-8) cos_(-8)
object about the origin, as shown in P'(x', y')
the Fig. Q.3.2. = fcos 0 -sin 8] ·: cos (-8)= cos 8 and ... (9)
Lsin 0 cos 0 sin (- 8) = - sin 8
• Herc, r is the constant distance of the
point from the origin, angle IP is the Scaling
original angular position of the point •This operation can be carried out for polygons by multiplying the
from_ the horimntaI and e is the
rotation angle. 0 co-ordinate values (x, y) of each vertex by scaling factors Sx and SY to
produce the transfonned co-ordinates (x', y').
• standard trigonometric Fig. Q.3.2
-,-.ons, we can express the X = X·Sx
·
transformedco-ordinates m and ... (10)
, terms of angles 0 and q, as, y' = y,S
x, =r~s{q,+ 8)=rcos q, cos 8-rsin <I> sin 8 } • Scaling factor S scaies obiect in the x direction and scaling factor SY
Scales b' x th
Y =rsm(q,+0) =rcos q, sin 8+ rsin q, cos 8
J • •
... (4) Illa . 0 ~ect in the y direction. The equation (10) can be wntten m e
• The original co-ordinatesof th . , trix fonn as given below :
x=rco_sq, }
Y=rsm q,
e pomt m polar co-ordinates are given as,
... (5) [x'. y') =
[x y] [Sx0 SyO l
c?
A Guldefor E11g/J1eer/11gSt11det1tS

Downloaded by siddharth Patil (siddharthp718@gmail.com)


lOMoARcPSD|44103007

6-5 2D Transformations
6 _, 2D Trans/ormat1011s
~C~omp~IIIU~Gr~q~h~ics~-----~------------
, For two dimensional, transformations, we . . have the
can . homogeneous
[x·Sx y·Sy] ... 01) arameter W to be _any 110n zero value. But 1t 1s converuent to have
=

= p.5
t
= 1. Therefore, each two dimensional
with homogeneous co-ordinate as (x, y, 1).
position can be represented

20
, Summarizing it all up, we can say that the homogeneous co-ordinates
B' allow combined transfonnation, eliminating the calculation of
15 intermediate co-ordinate values and thus save required time for
15
transformation and memory required to store the intennediate
10 10 A' co~ordinatevalues.

0
rJ'
5 10 15
5

0 5 10 15 20
, The homogeneous co-ordinates for translation are given as,

T=[~ 0 ~J ... (I)


tX ty 1
(a) (b)
• The homogeneous co-ordinates for rotation are given as,
Fig. Q.3.3
cos sin e e o]
6.3 : HomogeneousCo-ordinates R = -sin 8 cos 8 O ... (2)
[
0 0 1
Q.4 What is homogeneous co-ordinate system ? Explain need of
homogeneous co-ordinates. Compare homogeneous and normalized • The h_omogeneous co-ordinate for scaling are given as,
co-ordinates. ~[SPPU : Dec.-05,16,18,May-07,12, Marks 8]

OR What is the need of homogenous co-ordinates ? Give the


s [s; s: ~]
.
=
0 0 I
... (3)

homogenous co-ordinatesfor translation,rotation and scaling.

~
8
•• : •
~[SPPU : Dec.-10,12, Marks 10)
In order to combine sequence of transfonnations we have to
[ 6.4 : Composite Transformation I
eliminate tbe matrix addition associated with the translation tenns in M2· Q,'S Explain the concept of 2D rotation about an arbitrary point
To ac~eve this. we have to represent matrix M1 as 3 x 3 matrix instead of ·
With lllatnx representation.
2 x 2 mtroducmg an dditi'Ona1 d
. a
by three numbers · ad wnm.y co-ordinate W. Here, points are· An~~SPPU : Dec.-13,15,16, 17, 18, M~y-15,16'. June-22, Marks 6)
specified
mste of two. This co-ordinate system 15 c · • To rotate an object about an arbitrary pomt, ("i,, Yp) we have to
called ho~ogeneou~ co-ordinate system and it allows us to express all
transformationequations as matnx· multi' li . 1arry out three steps :
p cation. W) · Translate point (x , y ) to the origin
• The homogeneous co O d' t • 2• llot t · .., P
where - r ma e ts represented by a triplet (Xw, y w• '
3 . a e It about the origin and
and y :::: · ;~ally, translate the center of rotation back where it belongs
x == ig. Q.s.1.
w

-eE:=,-,g~ln~tt~rl~ng~St=::u~d:,n~ts
~~==----=========-A-G=-u~ldfi~o-,
A Guidefor E11gl11eerl11gStudellts
Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007

C:

ComputerGraphics 6-6 2D Tra11sfor111ations Computer Grapl,ics 6-7


2D Trans/ormations

[~::r:!{
, Therefore, the overall transformation matrix for a counterclockwise
L-...----x

(a) Rotationabout an
arbitrary point
(b) Step 1 : Translate point
(xp, Yp) to the origin
T~::~[ angl~ e riout 1]is gi[T '\ ~1
-Xp -y p 1 0 0 1 Xp yp 1
y
(x', y'}

(x,y~1- =[ -:~:: ;~::


;J l.: y: ;J
(x', y'}

-xp cos 8+y p sin 8 -xp sin 8-y P cos 8


(x, y) /,, (xp, Yp)

l
,______ x 8 ~8
~----x
{c) Step 2 : Rotate It
about the origilf
(d) Step 3 : Translate back
to the origina l position
=
-xp
· -:~: 8
cos 8 + y P sin 8 + xp -xp
cos 8
sin 8-y p cos 8 + Yp ~]
Fig. Q.5.1 ... (1)
CU· Prove that two 2D rotations about the origin commtJte; that is
• Matrix multiplicationis not commutative, i.e. multiplying matrix A by
R1R·2 =R 2 R 1 , ~[SPPU : Dec.-10, Marks 8)
matrix B will not always yield the same result as multiplying matrix B
. Ans.: .We have
by matrix A. Therefore, in obtaining composite transformation matrix,
we must be careful to order the matrices so that they correspond to the
order of the transformationson the object. _ R1R2
cos 8 · sin 8 l[ cos 82
= [ -sin 81 cos 81· -sin 82 cos 82
sin 82] and

• The lransl:n=malru<[
: ~~~•~Joint<x,, Y,) _
to the origin is given as, R2R = [ cos 82 sin 82
1
1

-sin 8 2 . cos 82.


1
l[ co_s 81 sin 81]
-sm 81 cos 81
-xp -y P 1 · 8 1sm
cos 8 1 . cos 8 2 - sm · 82 cos 8 1 -sin82 -sin8 1cos02]
[ -sin 81 •cos 82 -cos 81sin 82 -sin 81 •sin 82 +cos 81 cos ~2
• ~e, r~tati?n matrix for counterclockwiserotation of point about the
ongm 1s given as,
a
R = [-:~::
0
:: :
0
~1
1
R. 2 1 == [ cos 02 •cos 81 -sin 8 2 sin 81


·
lice,
cos 82 •sin 81 +sin 82 -cos 81 ]
-sin 8 2 •cos 8 1 -cos 8 2 sin 81 -sin 82 •sin 81 +cos 82 •cos 81
multiplication is commutative cos 81 •cos 8 2 COS 82 •COS 81,

• The translation matrix to move the ·gjnal erefore, R1R.2 = R2R1.


position is given as, eenter point back to its on

A Guldefor E11gh1eerl11gS,111lents

Downloaded by siddharth Patil (siddharthp718@gmail.com)


lOMoARcPSD|44103007

-
Computer Graphics 6-9 2D Transformations
6-8 2D Transformatio,,s
ComputerGraphics

Q 7 A 2D rectangular block with 1 unit height and 2 units width has


o~e vertex "A" at origin. The block is shifted by 1 unit in
X-direction and scaled by 2 units along Y-direction. Draw initial
state of the rectangle and transformed final state of given rectangle.
Give complete ~athematical formulation.
2

---- I
I
I
I
I
I
I
I
:h_ :Le_
0 1 2 0 1 2

~[SPPU : May-11, Marks 18] Fig. Q.8.1 Fig. Q.8.2 Fig. Q.8.3
Ans.: Ans. : The scaling matrix is

~l
Sx 0
S = 0 Sy
T = [; : ;] [
0 0

[H ;]
Here Sx = 0.5, • SY =1
TS =

Co-ordinates of rectangle are :


A(0,0), B(0,l), C(2,l), D(2,0)
s [°t ! ~l
The translation matrix is

[i] =[ iJ [H ;J Fig. Q.7.1 Initial state


T [ ,: ,: ;]

l
y

t
{ iil 2

Fig. Q.7.2 Final state


3
•• = I, :

The overall transformation matrix is


0.5
S.T. =
[
Q.B Fig. Q.8.1 and Fi

~1
Q
translation and scalin g. ·8•2 show basic 2D blocks, ApplY
. g transformatio
diagrams of all interm di t
e a e steps.
t .
ns O get the Fig. Q.8.3,
vra-W
= [o~s 1 1 1
q:,[SPPU : May-1 O, Marks 1SJ
By applying this transformatjon to a triangle (0, 0), (1, 1), (2, 0), we get
"""---
~;:c:;:~:::l)::.,:==a======================
A Gulde for E11gl11eerlngStudents
A Gulde for E11glneerl11gStlldef1IS
Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007

ComputtrGl'fll'hics 6-10 2D Trans/orrnatio,,s


- computerGrapi,ics 6-11
2D Trans/ormations

[~ ~l[oos ~1 =[1'.s_: :]
201 111 211
After applying scaling transfonnationto Fig. Q.8.2,
given as,

R =
[
cos 8 -sin 8 0
sin 8 cos 8 0
0 0 I
l
The rotation matrix for clockwise rotation of point about the origin is

:L
0 1 2

After applying translationtransformationto above figure,


The translationmatrix to move the center point back to its original

position is g:: :' [


Xp
0

Yp
~I ]

Therefore, the overall transformation matrix for a clockwise rotation by an

:tt_
0 1 2
angle e about the point ( xp , y P ) is given as -

T1 ·R ·T2 =[
-xp -y P
0
~1 [:~: ~:i;e ~] uy: ~]
I O O
8

No transformationis applied to Fig. Q.8.1.


8
~:i:88 ~1 [ ~1
cos
:. By applying overall transformationwe get, :.T1·R·T2== sin0 ·
[
, y p sin 8
- Xp COS 8 - _ xp sin 8 - y P cos 8 I xii y P 1

,_JZ~ I
I [ ::es8 p -~ri8
cose :OJ
- "4===== = -xp w::.8-yp sin 8+xp , xp sin 0=yp cos8+yp
0~ I
2 Here, e : : 45°, Xp = 1 and y p = 0.
Q.9 Consider the square A(l, 0), B(0, 0), C(0, l) and D(l, 1). Sbo-W 1 ·
Subsftu
ting values we get,
the steps to rotate the given square by 450 clockwise about point
cos 45 -sin 45

n
A(l, O). · Q"[SPPU : Dec.-10, M~rks 10, June-22, Marks 6] T1 . R, T2 == sin 45 cos45
~ns. : The translation matrix to move point ( xp , y ) to the origin is [
given as, P . -cos 45 + I sin 45

1
- 0
1
0

Downloaded by siddharth Patil (siddharthp718@gmail.com)


, .... lOMoARcPSD|44103007

6. 12 2D Trans/orn1at1o>1s computerGrap/,ics 6-13 2JJ Transformations


Computu Grtlpldcs ---

re P(O, O), Q(O, 10), R(to, 10), S(lO, 0). Rotate


Q.10 Consider • squ~iseabout fixed point R(to, 10) by an angle 45°.
0
Owose sin 8
OJ [s,cos0e Sx sin 8
the square anticlockw :. SR= [8' Sy
0
-s~18 cos 8
0
= -s y ;in Sy COS 8
0 ~J
~[SPPU : May-19, Marks 4]
Where Sx =2, Sy= 2 and 8 = 450
0 sine
cos e
olo
Ans.: r =[ · _:: 8 2 cos 45 2 sin 45 OJ
-xpcos8+ypsin8+xp -xpsin8-ypcos8+yp I SR - 2 sin 45 2 cos 45 0
[
0 0 I
Note : Here, rotation is anticlockwise
Given : 8 = 45, Xp
J_
= 10 and Yp = 10
J_ 0 [~ ~] [~2 ~5 :~::: ~]
5 2 1 0 0 1
= r· 2.i281
4.2426 9.898
:J
1 1
0 Q,12 Perform scaling on a triangle (1, 1), (8, 1) and (1, 9) with
scaling factor of 2 in both x an~ y directions. Find the final
10 co-ordinatesof triangle. ~[SPPU : May-17, Marks 2]
Ans.:
1 l 10 -20 + io

F'] lo0 10o 1l] l


Q'
R:= 10 10 I -
1
'2
0

0
-10+10 -10+10 s [~ HJ
H~
v1. 10 10
IS 10 0 1 10 IQ_ + 10 -10 + 10
- 20 + 10

Q.11 Magnify the triangle with vertices A(O, 0), B(l, 1), C(S, 2) to
[!J [~ 9 i] [~ ; I~ i]
twice its siu IS well IS rotate it by 4S0 • Derive the translation The co-ordinatesof triangle are (2, 2), (16, 2), (2, 18).
13
matrices. ~(SPPU : Dec.-11,13, May-13, Marks BJ Q, For origin centered unit square, rotate 45° clockwise, scale b\ a
Ans.: factor 2 in x - direction. Find resultant co-ordinates of square (wnte
W[SPPU : Dec.-17, Marks 4]

s~ - q ~•m s {i .; ;] Md
required matrices).

Ans.:
R =
cos 45
sin/5
-si n 45~OJ
cos 45
[
0
Rotation matrix is given by R
[-c:Fe :~: ~]
-~s111de11ts
A Guide/orE11g/11eer/11g
Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007

6. U 2D Trans/orma110115 co,nputerGrap/lies 6-15 2D Transform,1tio'ls


~Co~mp~ut~e~rGr~ap~llics~--------------.__

[it-:: ~] [~ ~]
Ans, : The rotation matrix is,

l
cos 45 sin 45
R.S. = R = -sin 45 cos 45
o O l O O l
0 0

- o]0
. =

n Ir
0 0 l

-0.5
B'
c
D'
l-05
-0.5
0.5
0.5
0.5
0.5
-0.5
l
l
l
0
1/-n.
0 ~] T-R = [~
0
OJ [
0
1 0 0
OJ = [
0
1 0 ~]
{~ ,{z
0 -
0

0
0
ol
0
0
[i} [~
0
1J1 [
1 0
1/Ji 0OJ = [ 1/Ji
1 0 :]
14
~- Rotate origin centered square with 2 unit length· of each side, [ 6.5 : Reflection and Shear Transformations f
m clockwise direction with rotation angle of 900.
Q.1·s Explain the term reflection.
~[SPPU : May-18, Marks 3]
Am.: . ~[SPPU : May-12,19, Dec.-18, Marks 3]
Ans, : • A reflection is a transformation that produces a mirror image of
an object relative to an axis of reflection. .
p' = [-\ : ~s
-l -l Lsm8
]r 8 -sin 8] cos8
• We can choose
the xy plane.
an axis of reflection in the xy plane or perpendicular to

1 -1
Point to Remember

=: ]~
Q. 15 Find a transformationof
l[ }'.j
.
translating one unit in I and a triangle A(l, 0) B(0, 1) C(l, 1) b~
about the origin. Y directions and then rotating 45
q>[SPPU : Dec.-19, Marks 61

---?
t1e11ts
,. G11idefor E11g/11eerh1gSIii
A Gllidefor E11gineerfngStude11ts
Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007

6-16

--
Coltl/JuterGrapJ,ics

s-shear
6-17

, The x shear preserves the y co-ordinates, but


2D Tru11sforn,arions

changes the x values which causes vertical lines to


tilt right or left as shown in the Fig. Q .17.1 .
, The transfonnation matrix for x shear is given as -~
(a) Original object

1 0 OJ

iz-.
X_sh Shx 1 0
[ 0 0 ·1
x' x+Shx •y and
y' y ... (1) (b) Object after x shoar

Y Shear

J=i__
Fig. Q.17.1
• The y shear preserves the x co-ordinates, but
Reflection changes the y values which causes horizontal lines .
about line to transfonn into lines which slope up or down, as
shown in the Fig. Q.17.2.
y=x
• The transfonnation m2trix for y shear is given as 0 X

Reflection
about line
y=-x
"Y_:: [~} ~l i~••J••x
y' = y+Shy-x ... (2)
(bl Object after y shear

Table Q, 16•1 Common reflections Fig. Q.17.2


Q.17 What is shear transformation ? Explain X-shear and Y-sbear,
- 1 6,6 : Inverse Transformation I
~[S~PU : May-OB,or,12,14,16,Dec.-12,16, Marks 5]
Am. : • A transfonnationthat sl 16 th d the Q,18 E~plain inverse transformation and deriv~ the matrix for
shear transf~rmation. an e shape of an object is calle
inverse transformation.
• Two common shearing transfi · · • 3te
values and other 1.:A. ~ati011$ are used. One shifts x co-ordlll ~[SPPU : Oec.-06, 18, May-07, 08, Marks 8]
Sum~ y co-ordinate val H h cases
only one co-ordinate (x or ues. . owever, in both t e er ~s. : • When we apply any transfonnation to point (x, y) we get a n~w
. preserves its values. y) changes its co-ordinates and ofb Point (x' y') S ti' it may require to undo the apphed
tr"'"·" ' . opie mes . . . 1 . t (x y) from
-,onnation. In such a case we have to get ongma pom . '
the Point(x', y) This can be achieved by inverse transformation.
--....,
=-=<e!~-Yr·====-===a;;;;;;;,~ --~=~~~s de11ts
A Gultlefor E11gl11eeri11gStudents
A Guldefor E11gh1eerl11g Ill

Downloaded by siddharth Patil (siddharthp718@gmail.com)


lOMoARcPSD|44103007

6-18

---r· T
C.-prur Gnrptics 2D Trans/onnatio,,s
(,olfPutl1 Graphics
. 6-19
2D Transformations
. . .__ft~ormationuse.5 the matrix inverse of the transformation
• The mverse lflUIM' Th . f . .
• •. mq the ori...;..a1 point (x, y). e mverse o a matrix 1s another -d

.Ll
matri.x ~o "~· · 1· d t th
matrix such that when the two are multip 1e oge er, we get the b e 0
1 [ -b
e
- ae-bd a
identity matrix. d
c f 1 bf-ce cd-af
• If the inverse of matrix T is T -1, then
T T -l = T- T = I
1 , It is important to note that the elements of inverse matrix T -I can be
· · · (1)
where I is the identity matrix with all elements along the major calculated_from the element of T as
diagonal having value 1 and all other elements having value zero. (-l)i+ i det M•·
-1 Jl

I=[~~~]
0 0 1
tij = detT
In the above equation the term det T is in the denominator. Hence, we
can obtain an inverse matrix if and only if the determinant of the
... (6)

• The elements for the inverse matrix T -l can be calculated from the matrix is nonzero.
elements of T as
(-l)i+j det M·· END... 25
t··-l
lJ
= detT
J1 (2)
...
where tij -l is the element~ the i row th
and j th column _of T- 1 and ~i
is the (n - 1) by (n-1) submatrix obtained by deleting the j th row and
im column of the matrix A The det ~i and det T is the determinant of
the and T matrices.
• The determinantof a 2 x 2 matrix is
l tu tu ,
det I t , = t 11 ·t 22 -tu -t 21 ... (3)
I 21 t22 :

• The determinantof a 3 x 3 matrix is


det T = tu. (tn ~3 - ~i) - t12. (½1 ~3 - ½3 ~1)
+ t13. <ti1 ~2 - 1n ~1) ... (4)
• In general form. the determinantof T is given by .
det Tj = L tij (- 1) i + j det ~j ... (5)

matrix"i:
where M .. is the submatrix ~- - by d .
lllllllCQ
ci · froIJl
e1eting row i 3n:d column J

• The inverse of the homogeneous CO-ordinat tr . triX can


be given as e ans,onnation ma

A Guldtfor Englnttrlng Studtt1fS

Downloaded by siddharth Patil (siddharthp718@gmail.com)


lOMoARcPSD|44103007

co,nputerGrap!,lcs 7- 2
3D Transformations and Projections

0 0 y

\17 II 3D Transformations
and Projections
s
= [1 Sy

0
0 Sz
0
0

!] ,~
'I

(Sx, sy,s, 1

Ll::::======u P' P·S

1, .1 : 3D Translation I Fig. Q.2.1 3 D Scaling

Q.1 Obtain the 3D transformationmatrices for translation. [ x' y' z'l]= [x y z 1] s~ox s~oy so~zoloo]
[SPPU : Dec.-05,07,08,May-05,07,08,18, Marks 2] [
Ans. : • Three dimensional transformation matrix for translation with
homogeneous coordinates is as given below. It specifies three coordinates
with their own translationfactor. ... (1)
0
1 0
0 0 ol j , .3 : 3D Rotation /
T =[~ 0 1. 0
Q.3 Obtain the 3D transformation matrix for rotatio!} about z-axis.
tx ty t2 1
~[SPPU : May-11,19, Marks 3]
p' = P-I
OR Explain the rotation about all co-ordinate axis.

[x y' z'l]=[x y z l] [~ ~1 ~[ SPPU : .May-06, 07, Dec.-16,18, Marks 8]

t: t: t: OR Give homogenous
respect to y axis.
transformation
[ SPPU : May-16, Marks 2 ]
matrix for 3D 'rotation with

Ans. : • Three dimensional transformation matrix for each co-ordinate


= [x+1x Y'+\ z+tz l] ... (1)
axes rotations with homogeneous co-ordinate are as given below.
~-2: 3D
Q.2 Obtain 3D transformationmatris. fo
ScalingJ . . y . • y

lin
~[SPPU · Ma -o r aca g.
871 cose sine o 0]
An · Y s, oa, 16, Dec.-os, 07 08 16 18 Marks 2] Rt• --elne cose . o o
s. : • Three dimensional tr fi . ' ' ' ' 'tb [ 0 0 1 0
homogeneousco-ol'dinatesis onnation matrix for scaling WI 0 0 0. 1
•I • · as given below.
t specifies three co-ordinateswith th . .
• CU' own scaling factor.
X Z
(I)
(b) (c)
(7 - 1) Fig. Q,3.1 Rotation about z axis

Downloaded by siddharth Patil (siddharthp718@gmail.com)


lOMoARcPSD|44103007

~~~'.::,_----------~--- 3D Transformationsand Pro)ect1o,,s 7-4

---
ComputerGr11Pltics 7. 3 Cof/lPuterGraphics 3D Transformationsand Projections

• The pos1·n·ve val"'·


..., of angle 8 indicates
. counterclockwise
. rotation. For 1. Translate the object so that rotation axis specified by unit vector
clockwiserotation value of angle 8 is negative. u passes through the coordinate origin. (See Fig. Q.4.1 (a) and
{b))

0 c:ose
0 sin80 0~0
f\ = 0 -sin8 c:os8 0
0 0 0 1

X Z
(•) (b) (c)
a) Axis of rotation b) Translation of the
defined by .points rotation axis to the
Fig. Q.3.2 Rotation about x axis P1 and P2 coordinate origin

l
0 o
Ry= cose 1
sin8
0 0
0
o cose o
0
0

1
0 ~/
I

X .
<•> {b)
(c)
c) Rotation of unit d) Rotation of unit
Fig. 0.3.3 Rotation about y axis vector about x axis to vector u about y axis
bring It Into xz plane to align It with the z axis

f. 4
' llolationabout ArbitraryAxis
Q.4 Derive the tramformati .
I Fig. Q.4.1
arbitrary uis. on matrix for rotation about any 2
· Rotate the object so that the axis of rotation coincides with one
of the coordinate axes. Usually the z axis is preferred. To
q- [SPPU : May-11 • 12, Marks 10 Dec.-11, Marks 12) coincide the axis of rotation to z axis we have to first perform
OR Explain the concept of 3D ro . rotation of unit vector u about x axis to bring it into xz plane
q- [SPPU . Ma i.tton about any arbitrary axis, and then perfonn rotation about y axis to coincide it with z axis.
· · y-O&,oa,12,14, Dec.-o&,07,08,14,Marks 8 (See Fig. Q.4.1 (c) and (d))
3
Perfonn the desired rotation 8 about the z axis.
Ans. : • When an object is to be ro June-22, Marks 61 4'
to one of the coordinate tated about an axis that is not paralle1 ' J\~ply the inverse rotation about y axis and th~n about x axis to
transformations.The sequenc:esf,thewe have to perform some additional bnng ·the rotation axis back to its original orientation.
o se transti0 . . .
nnations 1s given below, S, 0Apply the inverse translation to move the rotation axis back to its
••
l'lginal position
A Guldefor Engl11eerl11gSt11deJIIS
.
A G1tidefor E11gh1eeri11gStudents
Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007

---
7-5 3D Transformationsand Projectio,,s
Computer Grapltics
7-6 · 3D Transformationsand Projections
Derivation of transformationmatrix
The translationl~;mx i~ give~as • BY substitutingvalues of cos a and sin a the rotation matrix
given as
can be

O 1 0
T= O O 1
0100 1 c/d0
0
0 OJ
bi d 0
Rx =
-X1 -yl -z1 1 [0 -b / d c/d 0
• To perform the rotation of unit vect~r u about X axis. The rotation 0 0 0 1
of u
around the x axis into the xz plane is accomplishedby rotating u' , To perform the rotation of unit vector about y axis. This
(0, b, c) through angle a into the z axis and the cosine of the can be
rotation achieved by rotating u" (a, 0, d) through angle Ponto the z axis.
angle a can be determined from the dot product of u' and the unit Using
similar equations we can determine cos P and sin pas follows.
vector Uz (0, 0, 1) along the z axis.
• We have angle of rotation = - P
u'•u c
cos a= lu'I ; = d where u' (0, b, c) = bJ + cK and
=I:,,i°J~zl where u"=
II

1 21
cos (- P) = cos P al+ dK and
Uz (0, 0, 1) = K
.c K
--- - Uz
1u' 1, uz , d
= _c_ lu"I /uzl
u' Since luzl =1
- d
C - ju"/ IUzl = 1
ci
where d is the magnitude of u'. d
d = b2 +c2 .Ja2+d2
• Similarly, we can determine th . · • Consider cross product of u" and ·Uz
and llz· e sme of <X from the cross product of u,
u" x u2 = _ lu';I !Uzi sin (- B)
u' x Uz = 11x lu'I luJ sin ex
and the Cartesian t; (1) = - ·uy lu "I
iuzl' sin B sin (- 0) ==:= - sin 0
, · orm for the cross product · . ··· • Cartesian
·
u x Uz = ux ·b form of cross product gives us
gives us
... (2) u" x uz = lly (+a)
• Equating the right sides of · • Equat'
11x lu'I IUzl · sin ex =eq~~0 :S (1) and (2) we get ing a~ove equation~,
- Iu I Iu 2 I sin p = a
lu'I luJ sin ex = b
-a
sin ex b sin B - Itl,, IIu z I
lu'i luzl -a
= b
IUzl = 1
d since l~I = 1 and lu 'I = d
-a
I.!
de11/S
A Guldefor E11gt11eerh1gStll
Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007

Computu Grt1pl,ics 7- 7 3D Transformationsand ProJectio,rs


7
.,, Grap/lies
co...muter •8 3D Transformationsand Projections

but we have, d = .J b2 +c2 ADS,' Parallel projection is one in which z. co-ordinate is discarded
--: and
obJect are extended until they
parallel lines .from 1each vertex on the
d intersect the view p ane.
cos~= .Ja2+~2 = .Ja2+b2+c2
Q.7 What do you mean by perspective projection ?
-a -a
and sin~=-=== Ans, : Perspective projection is one in which the lines of projection are
.Ja2+d2 .Ja2+b2+c2 not parallel. Instead, they all converge at a single point called the center
By substitutingvalues of cos and sin in the rotation matrix and of projection.
by substitutingx = +c 2 and IVI = .Ja2 +b 2 +c 2 we have¾•
Q.8 What is projection reference point ?
Resultantrotation matrix = · Ry
Ans, : In perspective projection, the lines of projection are not parallel.
)... O a O Instead, they all converge at a single point called projection reference
I~ !VJ
--ab C b Q,9 Explain parallel and perspective projection ? .
¾ ,V1)... I 1v1 o · lli'[SPPU : Dec.-08,10,15, May-07,12,13,19, June-22, Marks 5]
-;te -b C Ans. : Parallel Projection
1v,. T -1 v1 °
~i
O 0
• In parallel projection, z co-ordinate is discarded and parallel lines from
O
each vertex on the object are extended until they intersect the view
plane.

:::
• The point of intersection
= [ -:::
0 0 1 O is the projection of the·
vertex.
0 0 0 1 View plane
. . ·•We connect the
• The overall transfonnati
then can be on matrix for rotation about an arbitrary axis Projected vertices by
line
transfonnations. expressed as the concatenation of five . individual segments which
correspend to
R(0) = T·Rxy ·Rz ·R;}-T-1 connections . on the
0 . .
n&ulal objec(
7.5 : Concept of Paran l • shown in the
e and Perspective Projections 18

t=
Q.5 Define projection. : Q,9.1, a parallel
ProJ~ction prese~es Fig. Q.9.1 Parallel projection of an object
Ans. : The process of dis · . relative
ob· .
proportions of to the view plane
3 ~ects b
projection. The projection D mto 2~ display unit is known. as ut does not
Prod
plane. onns 3D obJccts into a 2D projection , \lee the realistic views.
Pro· .of para11e1 projections are : Orthographic proiection
'fypcs and oblique
Q.6 What do you mean by parallel projection ? ~ectton.
J

#
A Guide/or Englneerh1gStudellls
A Guide for Eng/n,er/ng Students
Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007

7 • 1O ns
3D Transformationsand Projectio.:..:::_
7• 9 3D Transformationsand Pro}ectio1ts iputer Grapl,ics
:Co~mp~u~te~rG~r~ap,~,}t~ics~---------------------..:. ~--------------.......:... ____ __::..___:,:..=

Perspective Projec11on
• The perspectiveprojection, on ~e othe~ hand, produces realistic views
but does .not preserve relative proportions.
, In perspectiveprojection,the line~ of projection are not parallel
. fostead,
they all converge at a single point called the center of project ion or
projection reference point
• Toe object positions are transformed to the view plane along these
is
converged projection lines and the projected view of an object
of the converg ed- projecti on
determined by calculating the intersection
lines with the view plane, as shown in the Fig. Q.9.2. View plane
1;1ew plane
(front view) (side view)

(a) Orthographicparallel projection (b) Oblique parallel projection

View plane
Fig. Q.10.1

of an
• The orthographic projection can display more than one face
called axonom etric
',,,, ,_ ':. '..-:_2>,., object. S~ch an orthographic projecti on is
Converged ,, ',', ,,
0
rthogr~phic projection. .
prOjection '' <'...--':...~',
lines ::-,~,,
................. 'Axonometricprojections are of three types :
--.:--~-_..._Centerof • Isometric : All three principle axes are foreshortenedequally
.
· projection rtened equally .
.1 cti
• Dimetric : Two principle axes are foresho
Fig. Q.9.2 PersP9Ctiv,p lly.
ro,e on of an object to the view plane • Trimetric : All three principle axes are foreshortenedunequa
ed as the cavalie r and
'The oblique projections are further classifi
7.6: Types of Parallel Projections cabinet projections.
Q.10 Explain in detail typ angle
ea of parallel projection. • ~r the cavalier projection, the direction of projection makes a 45°
th the view plane. ·
• .
Ans. : • Parallel ProJection · IIif> [SPPU : June-2 2, Marks 6)
. s are b . ll . • ~n direction of projection makes an angle of arctan (2) = 63.4°
depending on the relation b asica Y categon zed into two types, th the ion.
etw.een the directio n of projecti on and the Wi the view plane, the resulting view is called a cabinet project
normal to the view plane.
• When the direction of the r . .
view plane, we have an o:b OJectton is normal (perpendicular) to the
G 7 : Types of Perspective Projections I
we have an oblique parallel o::~Ph!c parallel projection. OthefWise,
aQ,
1 Gt ·
1 Ve examples one .for each case of ~D obJects having 1") Never
types of parallel projection. p Jectton. Fig. Q. 10.1 illustrates the two ·
v1Vanish·lQg point ii) At most one vanishing pomt m
"') At most tw o
.
• Orthographic Projections are lllahing Point iv) At most three vanishing points.
_further classifie d as axonom et11c
orthographicprojectionand rnulti q, [SPPU : May-13, Marks 8; June-22, Marks 6)
view Orthographicprojection.
Q(@~IJCO~oi:)~•=========Guide===~--...;~:=:=~= A for E11g/11eerlt1g5t,1deiits
"'
Downloaded by siddharth Patil (siddharthp718@gmail.com)
-,,~gl:,,:::,t::,,:,,g:Sr::'.11a:e:11ts:
~~---.;a;;.=====;:;;i;::====A~G:,~,1d:-e~fo~r~E~
lOMoARcPSD|44103007

7• 11
~Co~mp~ut~er~G~r~ap~lt
3D Transformationsand Projections Co,rtputerGraphics 7-12 3D Transformationsand Projections
~ics~---_;_~.:__-------------
Ans.: y-axis
vanishing
point
I) Never a vanishing point :
It is a parallel project (Refer Q.9) t
II) At most one vanishing point . .
, Here the object is placed so that one of its surfaces 1s parallel to the·
plan; of projection.This is shown in the Fig. Q.11.1 (b).
, One point perspectiveprojections are simple to produce and find many
practicaluses in engineering,architecture,and in computer graphics.
.:;:t'.:> /i\\ }~~·
Vanishing point
· ···•::: :: _•••;•···L:.\·••·••·••·•• '. } /
,· ...........

(d) .Three-point perspective of a cube


(a) Fig. Q. 11.1 Perspective projections
Co-ordinate (ti)
dascnptlon One-point Iv)' At most three vanishing points .
perspective • A three-point perspective is achieved by positioning the object
projectlonof a cube so that
n?ne of its axes are parallel to the plane of projection. Althoug
h the
visual ~epth cues in a three-point perspective are stronger than
in the
two-p?mt perspective, the resulting geometrical deformations
are
sometnnes disturbing to the viewer.
• Fig. Q.11.1 (d) is a three-point perspective projection of a cube.
!~:
-.:..:..__
_Give ~ompa~ison between parallel and perspective projections.

(c)
Twe-polnts
-,---------------------
Sr.
No. Pa~allel Projection Perspective Projection
Ptr•PIICllve
pro)ect1onof a cube r--------------+-----------J
Fi.
~-f--<:1) a;~
111) At moat tw0 Q.11 ·1
l.

-s> .i~,.
. - --::tik.,->
. vanishing point
• In this projection, two surfac
the ~ase of a cube
this is ;~of the. object have vanishing points. In
Yb•ll)(lS, so that lines along that ~ved if the object is rotated along its
1
:-:-:~:-:-:r1
ut those al
ong the two other axll)(lsha
remain alt . P1ane
...ar el to the viewmg '
• Fig. Q.11.1 (c) shows a two . es ve Vanishing points.
-point perspectiveof a cube. View plane '
Centre ol
View plane projection

?
A Guidefor Englneerl11gStudellts

Downloaded by siddharth Patil (siddharthp718@gmail.com)


lOMoARcPSD|44103007

ComputerGraphics 7-13 3D Transformationsand Pro}ectio,rs


I

2. It is a projection where
co-ordinatesof the given object
It is a projection where
co-ordinates of the given object
-- -----
Colflputer Graphics

Ans, : •. The 3D
. . .
v1ewmg pro~ess 1~
7 14
- 3D Transformationsand Projections

inher~ntl~ more complex than the


20 viewing process. In. two . d11?ens10nal v1ewmg we have 2D window
are ~sformed by forming are transformed by forming
and ·2o viewport and ob~ects 111 the w_orld co-ordinates are clipped against
parallel lines to a view plane. converging lines also known as a
center of projection to a view
the window and are then transformed mto the viewport for display.
plane. • The complexity added in the three dimensional viewing is because of
3. Distance of the object from the Distance of the object from the
- the added dimension ~d the fact that even though objects are three
dimensional the display devices are only 2D.
center of projection is infinite. center of projection is finite.
4.
, The mismatch between 3D objects and 2D displays is compensated by
It produces accurate view of It does not produce accurate introducing projections.
various sides of the object to the view of various sides of the
view plane. object to the view plane; object , The. projections transform 3D objects into a 2D projection plane. The
size varies based on the distance Fig. Q.13.1 shows the conceptual model of the 3D transfonnation
from the view plane after process.
transformation.
• In 3D viewing, we specify a view volume in the world co-ordinates
s. It does not provide a realistic
It gives a realistic representation using modeling transforniation. The world co-ordinate positions of the
representationof an object. of an object objects are then converted into viewing co-ordinates by viewing
6. It preserves relative proportion of transformation.
It does not preserve relative
an object
proportion of an object. • Toe projection transformation is then used to convert 3D description
7. Types: of objects in viewing co-ordinates to the 2D projection co-ordinates. ·
Types:
1. Orthographicprojection •Finally, the workstation transformation transfonns the projection
1. One point perspective
2. Oblique projection. projection._ co-ordinatesinto the device co-ordinates.
Modelling
2. Two point perspective
projection.
CO.Ordinates World
co-ordinates
View
7
co-ordinates

.,,, d.~"tlepoint perspective


projection.
8. Parallel projections are best
Perspective projections are Projection Device
suitable for architectural co-ordinates
co-ordinates
drawings, where measurements s~table for creating realistic
are necessary. views.
Fig, Q_
.13.1 Conceptual model ·of 3D transformationprocess

Q.13 Explain with example


[,.e: 3D Vlewtng] 7.9 :· View Volumes and General
Projection Transformations _
3D vlewln .
q:,[SPPU . M~ . g transformation. . Q,14 l) , · ti
en.ve the transformation matrix for parallel proJec 00 •
. · Y-0&,13• Dec.-os,o&,07,11,17, Marks 8]
OR
Explam 3D viewing process with A... ~[ SPPU : May-06, Dec.-07,12, M~rks s_]
VarloUJ 3D viewing parameters, ·-.q, : • 'M. . ti n onto a given VIeW
P1-zi1 , .a.ne general equation of parallel proJec O )
q:,[SPPU · M
· ay-oa,15, Dec,-13, Marks 8] ,.. +'Alllnstead of xy plane in the direction of a given vector V (xp' Yp•
O\Vs :
-cz;;-
A Guidefor E11gf11eerh1gStude11 ts
A Gulde/or E11glneerl11gStude11ts
Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007

--ation and --
--s-- ectlo,,s
Pro)- Computer Graphics 7-16
3D Tran
7 _15__ ~-
______ -~ sform 3D Transformationsand Projections
:Co~m~IJJ:"~ter:~Gr~ap!:'.h:ics:..._
y
• Let us consider that Ro is matrix for perspectiveprojection.
Q.15 Derive the transformation
the view reference point, can be
Ans. : • The general pers pective-projection transformations
p I is the object point and

obtained by performing follo win g two ope ratio ns.
p2 is the projected pomt. ar to the view plane by
Now perform the , Make the cent er line of the frustum perpendicul
V = xpl + YpJ + zpK shearing the view volume.
following steps :
P1(X1, Y1, Z1) ing factor that depends on 1/z.
1. Translate the view , Scale the view volume. with a scal
reference point Ro •These two steps are illustrated in
Fig. Q.15.I.
of the view plane to
-----------x
the origin ~ing the
translationmatrix T. z
Ro
2. Perform an
Fig, Q.14.1

J
alignment (x,y,z)

al vector N of the view


transformation¾ so that the view normal to the xy plane.
plane points in the directionK, the norm
e.
3. 'Project point P1 on to the xy plan
2 and 1.
4. Perform the inverse of steps I

¾ ·Parv ·. R~ . r- 1 _View plane ,, View plane I 90°1


I
Parv,N,R0 = T · , z = 2vp
\
\
I
I
"A Center of window 1 , Center of window
0 n1 \ I

fNj 0 1,'
0 0
IN!
{i
0 0 0 Pr0Ject1on
l 0 -n1n2 n3 reference Projection (~rp• Yprp• 2 prp)
n2 0 1 0 0 Point , reference
T 0
0 jNj point

-yo -zo ;1 n3
0
-xP
Zp
-yp
:Zp
0 0

~NI '- IN!0 0 0 0 me to make Iha canterllna of Iha


0 0 Fig. Q.16.1 Shea~ng Iha vla\Y volu
view plane
'- -n1n2 frustum perpendicularto the
!NJ 0 'Dunn y, z) becomes position (x', y', z')
~NI 0 g shearing operation position (x,
give n as
n3 and its transformationmatrix is

II
0
T 0 1 00 010
r ~1
n1 '-
n3 0 1 0
!NJ0 INI !NJ0
0
Yo 1 [x' y' Z 1] [ X y z 1] [
j
Z0
0

This is the general equation of


.
ectio n on
.
the given view
_.:P'l' -bzp.;, 0
Para llel proJ
plane in matrix fonn. a == _ xprp -(x w min + Xw max) / 2
Where
Zprp

~r.;;;;;;;;;._..__=-=-=-=====A =7 7:-=~~~~::::
G11idtfor E11ginttringStudtnts
Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007
a;

7-17 compu,,,,, Graphics 7-18


Co,nplllu Grt1p/tics JD T'ransformationsand Pro)ectio,,s 3D Transformationsand Projections
ADS,: To bring vertex F to origin we need translation,
y -(Vwmin +Ywmax) / 2
b =- ---::-----
:::....!.::.!:..prp......:..... Yaxis
Zprp

• By matrix multiplicationwe get, H (0,2,0)


x' = x + a (z -1M,)
y' = y + b (z -1M,)
z' = z

• Once we have com·erted a position (x, y, z) in the original view volume


to pos11.1.on y-', z) in the sheared •view volume,
·.,; (x' , ~ • we •have
• (to, apply
, )
scaling transformation. During s~g ope~ti?n _position_ x , y , z
becomes (x"', y"', z) and its transformation matrix 1s given as
X axis
1 0 0 0
0 1 0 0 C
(2,0,2)
[,t y"' z 1] = [x' y' z 1] -xprp -yprp -1
zprp -zvp
1 Fig. Q.16.1 Initial state of cube
Zprp -zvp Zprp -zvp
XprpZ\rp 0 0
YprpZvp . Zprp
0 1 0
Zprp -zvp zprp -zvp T =
!]
Zprp -Zvp
• By matrix multiplicationwe get, [j 0
-2 -2
1
(
x" = x' z prp vp + x
I\_ zprp -z
-z ) (z -z)
-2_
prp z prp -z
A' 0 0 0
B' 0 0 2
y" = ·y' ( zprp -zvp ]+y (~) C' 2 0 2 0 0
zprp -z prp zprp -z P' 2 0 0 I
[ 01 0
• Therefore, the general perspective-projectiontransformation can be
expressed in matrix form as
Mperspecti ve = Mshear · Mscale
E'
F'
G'
0 2 2
2 2 2
2 2 0
-~ - _; -2 !]
Ii' 0 2 0
Q.16 A 3D cube dimen1iou Oength, breadth, and height) 2 units
each is placed in a 3D anti-clockwise ali, system such that one of its
vertex "A" is at the origin. (i.e. (0, 0, 0)) and vertex "F" in JD space,
Apply necessary transformation, such that vertex F becomes the
origin. Give complete mathematical formulation. Draw initial and
final state of the cube. q:,[SPPU : May.11, Marks 18] .

A G11id1for E11gl111erl11gStudelllS A Guldt for E11glnttr1ng Students


Downloaded by siddharth Patil (siddharthp718@gmail.com)
lOMoARcPSD|44103007

Co,nputerGraphics ;. 19 JD TranJ/ormatlon!Jll1td Pr
-- oJ,cu,,
A' -2 -2 -2 1 - "'
B' -2 - 2 0 1
C' 0 -2 0 1
D' 0 - 2 -2 1
=
E' -2 0 0 1
F' O· 0 0 1
G' 0 0 -2 1
H' -2 0 -2 1

Yaxis

H'(-2,0,-2)

EN»...i

Downloaded by siddharth Patil (siddharthp718@gmail.com)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy