of 57
5/24/2018 Computer Graphics Q n A's
1/57
Computer Graphics and Visualization 10CS65
VTU QUESTION PAPER SOLUTION
UNIT -1
INTRODUCTION
1. Briefly explain any t! appli"ati!n# !f "!$p%ter &rap'i"#. ()%ne *+1*, Ans: Applications of computer graphics are:
Display f !nformation Design Simulation " Animation #ser !nterfaces
*. Explain t'e "!n"ept !f pin'!le "a$era !f an i$a&in& #y#te$. Al#! /eri0e t'e
expre##i!n f!r an&le !f 0ie. ()%ne *+1*,
Ans :
#se trigonometry to find pro$ection of point at
%&'y'z(xp= -x/z/d yp= -y/z/d zp= d
)hese are e*uations of simple perspecti+e
2. Di#"%## t'e &rap'i"# pipeline ar"'ite"t%re3 it' t'e 'elp !f a f%n"ti!nal #"'e$ati"/ia&ra$. ()%ne *+1*, 1+
A
ns : Graphics ,ipeline :
,rocess o-$ects one at a time in the order they are generated -y the application
All steps can -e implemented in hard.are on the graphics card
Verte& ,rocessor
Dept/ of CS' CC ,age 1
5/24/2018 Computer Graphics Q n A's
2/57
Computer Graphics and Visualization 10CS65
uch of the .or2 in the pipeline is in con+erting o-$ect representations from one coordinatesystem to another
3 -$ect coordinates
3 Camera %eye( coordinates
3 Screen coordinates
+ery change of coordinates is e*ui+alent to a matri& transformation Verte& processor also computes +erte& colors
,rimiti+e Assem-ly
Vertices must -e collected into geometric o-$ects -efore clipping and rasterization can ta2eplace
3 4ine segments
3 ,olygons
3 Cur+es and surfaces
Clipping
ust as a real camera cannot see7 the .hole .orld' the +irtual camera can only see part of the.orld or o-$ect space
3 -$ects that are not .ithin this +olume are said to -e clippedout of the scene
8asterization :
!f an o-$ect is not clipped out' the appropriate pi&els in the frame -uffer must -e assigned colors
8asterizer produces a set of fragments for each o-$ect 9ragments are potential pi&els7
3 a+e a location in frame -ufffer
3 Color and depth attri-utes Verte& attri-utes are interpolated o+er o-$ects -y the rasterizer
9ragment ,rocessor:
Dept of CS' CC ,age ;
5/24/2018 Computer Graphics Q n A's
3/57
Computer Graphics and Visualization 10CS65
9ragments are processed to determine the color of the corresponding pi&el in the frame -uffer
Colors can -e determined -y te&ture mapping or interpolation of +erte& colors 9ragments may -e -loc2ed -y other fragments closer to the camera
. 4it' a neat /ia&ra$3 explain t'e "!$p!nent# !f a &rap'i"# #y#te$. (De" *+11,
An# 5 A Graphics system has 5 main elements :
!nput De+ices
,rocessor
emory
9rame
5/24/2018 Computer Graphics Q n A's
4/57
Computer Graphics and Visualization 10CS65
!n simple systems the C,# does -oth normal and graphical processing/
Graphics processing ? )a2e specifications of graphical primiti+es from application program and
assign +alues to the pi&els in the frame -uffer !t is also 2no.n as 8asterization or scan
con+ersion/
6. 4it' a neat /ia&ra$3 explain t'e '%$an 0i#%al #y#te$. (De" *+11, An#5
8ods are used for : monochromatic' night +ision
Cones Color sensiti+e
)hree types of cones
nly three +alues %the tristimulus+alues( are sent to the -rain
@eed only match these three +alues
3 @eed only threeprimarycolors
6/ De#"ri7e t'e !r8in& !f an !%tp%t /e0i"e it' an exa$ple. ()%ly*+11, 6An# 5 )he most predominant type of display has -een the Cathode 8ay )u-e %C8)(/
Various parts of a C8):
lectron Gun 3 emits electron -eam .hich stri2es the phosphor coating to emit light/
Dept of CS' CC ,age
5/24/2018 Computer Graphics Q n A's
5/57
Computer Graphics and Visualization 10CS65
Deflection ,lates 3 controls the direction of -eam/ )he output of the computer is con+erted -ydigital?to?analog con+erters o +oltages across & " y deflection plates/
8efresh 8ate 3 !n order to +ie. a flic2er free image' the image on the screen has to -e
retraced -y the -eam at a high rate %modern systems operate at=5z( ; types of refresh: @oninterlaced display: ,i&els are displayed ro. -y ro. at the refresh rate/
!nterlaced display: dd ro.s and e+en ro.s are refreshed alternately/
Dept of CS' CC ,age 5
5/24/2018 Computer Graphics Q n A's
6/57
Computer Graphics and Visualization 10CS65
UNIT -*
T9E OPEN:L
1. 4it' t'e 'elp !f a /ia&ra$3 /e#"ri7e t'e !pen :L interfa"e. ()%n*+1*,
An#5 penG4 pro+ides a po.erful -ut primiti+e set of rendering commands' and all higher?le+el
dra.ing must -e done in terms of these commands/
)he penG4 #tility 4i-rary %G4#( contains se+eral routines that use lo.er?le+el penG4
commands to perform such tas2s as setting up matrices for specific +ie.ing orientations and
pro$ections' performing polygon tessellation' and rendering surfaces/ )his li-rary is pro+ided
as part of e+ery penG4 implementation/
9or e+ery .indo. system' there is a li-rary that e&tends the functionality of that .indo.
system to support penG4 rendering/ 9or machines that use the B indo. System' the
penG4 &tension to the B indo. System %G4B( is pro+ided as an ad$unct to penG4/
G4B routines use the prefi& &l;/ 9or icrosoft indo.s' the G4 routines pro+ide the
indo.s to penG4 interface/
)he penG4 #tility )ool2it %G4#)( is a .indo. system?independent tool2it' .ritten -y
ar2 ilgard' to hide the comple&ities of differing .indo. system A,!s/
;/ 4rite explanat!ry n!te# !n5 i, R:B "!l!r $!/el< ii, in/exe/ "!l!r $!/el. ()%n*+1*,
An#5 Colors are indices into ta-les of 8G< +alues
8e*uires less memory
3 indices usually = -its
3 not as important no. emory ine&pensi+e
Dept of CS' CC ,age 6
5/24/2018 Computer Graphics Q n A's
7/57
Computer Graphics and Visualization 10CS65
@eed more colors for shading
!n inde&ed mode' colors are stored as indices/ !f there are 2 indices then there can -e 2n?1 colors
that could -e got -y com-ining red' green and -lue/ )his yields a huge color palette as compared
to the normal 8G< mode/
2. 4rite an !pen :L re"%r#i0e pr!&ra$ f!r *D #ierpin#8i &a#8et it' rele0ant "!$$ent#.
()%n*+1*, 1+
An#5 Einclude Fstdaf&/hF
Einclude G4Hglut/hI
typedef float
pointJ>KL HM initial
tetrahedron MH
point +JK NOO0/0' 0/0' 1/0P'
O0/0' 1/0' ?1/0P' O?1/0'
?1/0' ?1/0P' O1/0' ?1/0'
?1/0PPL
static G4float thetaJK N O0/0'0/0'0/0PL
int nL
+oid triangle% point a' point -' point c(
HM display one triangle using a line loop for .ire frame MH
O
glf+%a(L
glVerte&>f+%-(L
glVerte&>f+%c(L
5/24/2018 Computer Graphics Q n A's
8/57
Dept of CS' CC ,age
5/24/2018 Computer Graphics Q n A's
9/57
Computer Graphics and Visualization 10CS65
glnd%(L
P
+oid di+ideQtriangle%point a' point -' point c' int m(
O
HM triangle su-di+ision using +erte& num-ers
righthand rule applied to create out.ard pointing faces MH
point +1' +;'+>L int $L
if%mI0(
O
for%$N0L $>L $TT( +1J$KN%aJ$KT-J$K(H;L
for%$N0L $>L $TT( +;J$KN%aJ$KTcJ$K(H;Lfor%$N0L $>L $TT( +>J$KN%-J$KTcJ$K(H;L
di+ideQtriangle%a' +1' +;' m?1(L
di+ideQtriangle%c' +;' +>' m?1(L
di+ideQtriangle%-' +>' +1' m?1(L
P
HM dra. triangle at end of recursion MHelse%triangle%a'-'c((L
P
+oid tetrahedron% int m(O
HM Apply triangle su-di+ision to faces of tetrahedron/Gi+ea different color to each face of the tetrahedronMH
glColor>f%1/0'0/0'0/0(L
di+ideQtriangle%+J0K' +J1K' +J;K' m(L
glColor>f%0/0'1/0'0/0(L
di+ideQtriangle%+J>K' +J;K' +J1K' m(L
glColor>f%0/0'0/0'1/0(L
di+ideQtriangle%+J0K' +J>K' +J1K' m(L
glColor>f%0/0'0/0'0/0(L
di+ideQtriangle%+J0K' +J;K' +J>K' m(L
P
Dept of CS' CC ,age =
5/24/2018 Computer Graphics Q n A's
10/57
Computer Graphics and Visualization 10CS65
+oid display%+oid(
O
glClear%G4QC48Qtetrahedron%n(L
gl9lush%(L
P
+oid my8eshape%int .' int h(
O
glVie.port%0' 0' .' h(L
glatri&ode%G4Q,8C)!@(L
gl4oad!dentity%(L
HM code to maintain the aspect
ratioMH HM hen .idth -ecomes lessthan height' ad$ust the -ottom'top parameters
to maintain the aspect ratioMH
if %. N h(
glrtho%?;/0' ;/0' ?;/0 M %G4float( h H %G4float(.' ;/0 M %G4float( h H %G4float( .' ?10/0' 10/0(L
HM hen height -ecomes less
than .idth' ad$ust the left'right parameters tomaintain the aspect ratioMH
else
glrtho%?;/0 M %G4float( . H %G4float( h';/0 M %G4float( . H %G4float( h' ?;/0' ;/0'
?10/0' 10/0(L
glatri&ode%G4QD4V!(L
glut,ost8edisplay%(L
P
+oid main%int argc' char MMarg+(
O
printf%Fenter the no of di+ision :F(L scanf%FdF'"n(L
glut!nit%"argc' arg+(L
glut!nitDisplayode%G4#)QS!@G4 U G4#)Q8G< U G4#)QD,)(Lglut!nitindo.Size%60' =0(L
glutCreateindo.%F>D Gas2etF(L
glut8eshape9unc%my8eshape(L
Dept of CS' CC ,age W
5/24/2018 Computer Graphics Q n A's
11/57
Computer Graphics and Visualization 10CS65
glutDisplay9unc%display(L
glna-le%G4QD,)Q)S)(L
glClearColor %1/0' 1/0' 1/0' 1/0(Lglutain4oop%(L
P
. 4it' a neat /ia&ra$3 /i#"%## t'e "!l!r f!r$ati!n. Explain t'e a//iti0e an/ #%7tra"ti0e
"!l!r#3 in/exe/ "!l!r an/ "!l!r #!li/ "!n"ept. (De"*+11, 1*
An#5
A +isi-le color can -e characterized -y the function C%X(
)ristimulus +alues 3 responses of the > types of cones to the colors/
> color theory 3 !f ; colors produce the same tristimulus +alues' then they are +isually
indistinguisha-le/7
Additi+e color model 3 Adding together the primary colors to get the percie+ed colors/
/g/ C8)/
Su-tracti+e color model 3 Colored pigments remo+e color components from light that is
stri2ing the surface/ ere the primaries are the complimentary colors : cyan' magenta and
yello.
R:B "!l!r
ach color component is stored separately in the frame-uffer #sually = -its per component in -uffer
@ote in &lC!l!r2fthe color +alues range from 0/0 %none( to 1/0 %all(' .hereas in
&lC!l!r2%7 the +alues range from 0 to ;55
)he color as set -y &lC!l!r-ecomes part of the state and .ill -e used until changed
Dept of CS' CC ,age 10
5/24/2018 Computer Graphics Q n A's
12/57
Computer Graphics and Visualization 10CS65
3 Colors and other attri-utes are not part of the o-$ect -ut are assigned .hen the
o-$ect is rendered
e can create conceptual vertex colors-y code such as
&lC!l!r
&lVertex
&lC!l!r
&lVertex
8G
An#5 indo.3A rectangular area of our display/
odern systems allo. many .indo.s to -e displayed on the screen %multi.indo.en+ironment(/
Dept of CS' CC ,age 11
5/24/2018 Computer Graphics Q n A's
13/57
Computer Graphics and Visualization 10CS65
)he position of the .indo. is .ith reference to the origin/ )he origin %0' 0( is the top leftcorner of the screen/
&l%tInit(,
allo.s application to get command line arguments and initializes system/)he function is
-asically used for initializing the glut li-rary and also to initiate a session .ith the .indo.s
system/ )he function does not ta2e any arguments and should -e the first function to -e
called .ithin the main program/
&l%InitDi#play!/e(, re*uests properties for the .indo. %therendering context(
8G< color? specified -y the argument G4#)Q8G color modeneeds to -e used/
Single -uffering 3 G4#)QS!@G4: specifies that the images are static and only asingle frame -uffer is re*uired to store the pi&els
G4#)QD#KL HM initial
tetrahedron MH
point +JK NOO0/0' 0/0' 1/0P'
O0/0' 1/0' ?1/0P' O?1/0'
?1/0' ?1/0P' O1/0' ?1/0'
?1/0PPL
static G4float thetaJK N O0/0'0/0'0/0PL
int nL
+oid triangle% point a' point -' point c(
5/24/2018 Computer Graphics Q n A's
14/57
Dept of CS' CC ,age 1;
5/24/2018 Computer Graphics Q n A's
15/57
Computer Graphics and Visualization 10CS65
HM display one triangle using a line loop for .ire frame MH
O
glf+%a(L
glVerte&>f+%-(L
glVerte&>f+%c(L
glnd%(L
P
+oid di+ideQtriangle%point a' point -' point c' int m(
O
HM triangle su-di+ision using +erte& num-ers
righthand rule applied to create out.ard pointing faces MH
point +1' +;'+>L int $L
if%mI0(
O
for%$N0L $>L $TT( +1J$KN%aJ$KT-J$K(H;L
for%$N0L $>L $TT( +;J$KN%aJ$KTcJ$K(H;L
for%$N0L $>L $TT( +>J$KN%-J$KTcJ$K(H;L
di+ideQtriangle%a' +1' +;' m?1(L
di+ideQtriangle%c' +;' +>' m?1(L
di+ideQtriangle%-' +>' +1' m?1(L
P
HM dra. triangle at end of recursion MHelse%triangle%a'-'c((L
P
+oid tetrahedron% int m(
O
HM Apply triangle su-di+ision to faces of tetrahedron/Gi+ea different color to each face of the tetrahedronMH
glColor>f%1/0'0/0'0/0(L
di+ideQtriangle%+J0K' +J1K' +J;K' m(L
glColor>f%0/0'1/0'0/0(L
di+ideQtriangle%+J>K' +J;K' +J1K' m(L
Dept of CS' CC ,age 1>
5/24/2018 Computer Graphics Q n A's
16/57
Computer Graphics and Visualization 10CS65
glColor>f%0/0'0/0'1/0(L
di+ideQtriangle%+J0K' +J>K' +J1K' m(L
glColor>f%0/0'0/0'0/0(L
di+ideQtriangle%+J0K' +J;K' +J>K' m(L
P
+oid display%+oid(
O
glClear%G4QC48Qtetrahedron%n(L
gl9lush%(L
P
+oid my8eshape%int .' int h(O
glVie.port%0' 0' .' h(L
glatri&ode%G4Q,8C)!@(L
gl4oad!dentity%(L
HM code to maintain the aspectratioMH HM hen .idth -ecomes less
than height' ad$ust the -ottom'top parametersto maintain the aspect ratioMH
if %. N h(
glrtho%?;/0' ;/0' ?;/0 M %G4float( h H %G4float(.' ;/0 M %G4float( h H %G4float( .' ?10/0' 10/0(L
HM hen height -ecomes less
than .idth' ad$ust the left'right parameters tomaintain the aspect ratioMH
else
glrtho%?;/0 M %G4float( . H %G4float( h'
;/0 M %G4float( . H %G4float( h' ?;/0' ;/0'
?10/0' 10/0(L
glatri&ode%G4QD4V!(L
glut,ost8edisplay%(L
P
+oid main%int argc' char MMarg+(
O
printf%Fenter the no of di+ision : F(L
Dept of CS' CC ,age 1
5/24/2018 Computer Graphics Q n A's
17/57
Computer Graphics and Visualization 10CS65
scanf%FdF'"n(Lglut!nit%"argc' arg+(L
glut!nitDisplayode%G4#)QS!@G4 U G4#)Q8G< U G4#)QD,)(Lglut!nitindo.Size%60' =0(L
glutCreateindo.%F>D Gas2etF(L
glut8eshape9unc%my8eshape(L
glutDisplay9unc%display(L
glna-le%G4QD,)Q)S)(L
glClearColor %1/0' 1/0' 1/0' 1/0(L
glutain4oop%(L
P
@. Cla##ify t'e $a!r &r!%p# !f API f%n"ti!n# in !pen :L. Explain any f!%r !f t'e$.
()%ly*+11,
Ans:
,rimiti+e functions: Defines lo. le+el o-$ects such as points' line segments' polygons
etc/
Attri-ute functions : Attri-utes determine the appearance of o-$ects
o Color %points' lines' polygons(
o Size and .idth %points' lines(
o ,olygon mode
Display as filled
Display edges
Display +ertices
Vie.ing functions: Allo.s us to specify +arious +ie.s -y descri-ing the cameraYs
position and orientation/
)ransformation functions: ,ro+ides user to carry out transformation of o-$ects li2e
rotation' scaling etc/
!nput functions : Allo.s us to deal .ith a di+erse set of input de+ices li2e 2ey-oard'
mouse etc
Control functions: na-les us to initialize our programs' helps in dealing .ith any errorsduring e&ecution of the program/
Zuery functions: elps *uery information a-out the properties of the particular
implementation/
Dept of CS' CC ,age 15
5/24/2018 Computer Graphics Q n A's
18/57
Computer Graphics and Visualization 10CS65
>. 4'at i# an attri7%te it' re#pe"t t! &rap'i"# #y#te$= Li#t attri7%te# f!r line# an/
p!ly&!n#. ()%ly*+11,
An#5 Attri-ute functions : Attri-utes determine the appearance of o-$ects
Color %points' lines' polygons(
Size and .idth %points' lines(
,olygon mode
Display as filled
Display edges
Display +ertices
,olygons : -$ect that has a -order that can -e descri-ed -y a line loop " also has a .ell definedinterior
. Li#t !%t /ifferent !pen :L pri$iti0e#3 &i0in& exa$ple# f!r ea"'. ()an*+1+, 1+
Ans: penG4 supports ; types of primiti+es:
Geometric primiti+es %+ertices' line segments/( 3 they pass through the geometricpipeline
Dept of CS' CC ,age 16
5/24/2018 Computer Graphics Q n A's
19/57
Computer Graphics and Visualization 10CS65
8aster primiti+es %arrays of pi&els( 3 passes through a separate pipeline to the frame -uffer/4ine segments
G4Q4!@S
G4Q4!@QS)8!,
G4Q4!@Q4,
1+. Briefly explain t'e !rt'!&rap'i" 0iein& it' Open:L f%n"ti!n# f!r */ an/ 2/ 0iein&.In/i"ate t'e #i&nifi"an"e !f pr!e"ti!n plane an/ 0iein& p!int in t'i#. ()an*+1+, 1+
An#5 !n the default orthographic +ie.' points are pro$ected for.ard along theza&is onto theplanez=0
Tran#f!r$ati!n# an/ Viein& )he pipeline architecture depends on multiplying together a num-er of transformation matrices to
achie+e the desired image of a primiti+e/ ).o important matrices :
odel?+ie.
,ro$ection
)he +alues of these matrices are part of the state of the system/
!n penG4' pro$ection is carried out -y a pro$ection matri& %transformation(
)here is only one set of transformation functions so .e must set the matri& modefirst &latrix!/e (:LPRO)ECTION,
)ransformation functions are incremental so .e start .ith an identity matri& and alter it .ith apro$ection matri& that gi+es the +ie. +olume
&lL!a/I/entity(,
5/24/2018 Computer Graphics Q n A's
26/57
Computer Graphics and Visualization 10CS65
glVerte&;f%0/ M cos%angle(T0/5' 0/ M sin%angle(T0/5(glVerte&;f%0/5 M cos%angle(T0/5' 0/5 M sin%angle(T0/5(
P
glnd%(L
-rea2L
P
P
. Explain Pi"8in& !perati!n in !pen:L it' an exa$ple. ()%l*+11, 6
An# 5 !dentify a user?defined o-$ect on the display
!n principle' it should -e simple -ecause the mouse gi+es the position and .e should -ea-le to determine to .hich o-$ect%s( a position corresponds
,ractical difficulties,ipeline architecture is feed for.ard' hard to go from screen -ac2 to.orld Complicated -y screen -eing ;D' .orld is >D
o. close do .e ha+e to come to o-$ect to say .e selectedit[ +oid mouse %int -utton' int state' int &' int y(
O
G4#int name
5/24/2018 Computer Graphics Q n A's
27/57
Computer Graphics and Visualization 10CS65
HM same clipping .indo. as in reshape call-ac2MH glurtho;D%&min'&ma&'ymin'yma&(L
dra.Qo-$ects%G4QS4C)(L
glatri&ode%G4Q,8C)!@(L
HM restore +ie.ing matri&MH gl,opatri&%(L
gl9lush%(L
HM return -ac2 to normal render mode MH
hits N gl8enderode%G4Q8@D8(L
HM process hits from selection mode renderingMH
processits%hits' namef%1/0'0/0'0/0(gl8ectf%?0/5'?0/5'1/0'1/0(L
if %mode NN G4QS4C)(gl4oad@ame%;(L
glColor>f%0/0'0/0'1/0(gl8ectf%?1/0'?1/0'0/5'0/5(L
P
+oid processits%G4int hits' G4#int -ufferJK(
O
unsigned int i'$L
P
Dept of CS' CC ,age ;5
5/24/2018 Computer Graphics Q n A's
28/57
Computer Graphics and Visualization 10CS65
UNIT
:EOETRIC OB)ECTS AND TRANSKORATIONS-1
1. Explain t'e "!$plete pr!"e/%re !f "!n0ertin& a !rl/ !7e"t fra$e int! "a$era !r eye
fra$e3 %#in& t'e $!/el 0ie $atrix. ()%n*+1*, 1+
An#5 4!rl/ Spa"e
-$ect space for a particular o-$ect gi+es it no spatial relationship .ith respect to other o-$ects/
)he purpose of world space is to pro+ide some a-solute reference for all the o-$ects in your
scene/ o. a .orld?space coordinate system is esta-lished is ar-itrary/ 9or e&le' you may
decide that the origin of .orld space is the center of your room/ -$ects in the room are then
positioned relati+e to the center of the room and some notion of scale %!s a unit of distance a foot
or a meter[( and some notion of orientation %Does the positi+e y?a&is point FupF[ !s north in the
direction of the positi+ex?a&is[(/
T'e !/elin& Tran#f!r$
)he .ay an o-$ect' specified in o-$ect space' is positioned .ithin .orld space is -y means of a
modeling transform/ 9or e&le' you may need to rotate' translate' and scale the >D model of a
chair so that the chair is placed properly .ithin your room_s .orld?space coordinate system/ ).o
chairs in the same room may use the same >D chair model -ut ha+e different modeling
transforms' so that each chair e&ists at a distinct location in the room/
Rou can mathematically represent all the transforms in this chapter as a & matri&/ #sing theproperties of matrices' you can com-ine se+eral translations' rotations' scales' and pro$ections
into a single & matri& -y multiplying them together/ hen you concatenate matrices in this
.ay' the com-ined matri& also represents the com-ination of the respecti+e transforms/ )his
turns out to -e +ery po.erful' as you .ill see/
!f you multiply the & matri& representing the modeling transform -y the o-$ect?space position
in homogeneous form %assuming a 1 for the wcomponent if there is no e&plicit wcomponent('
the result is the same position transformed into .orld space/ )his same matri& math principle
applies to all su-se*uent transforms discussed in this chapter/
Eye Spa"e
#ltimately' you .ant to loo2 at your scene from a particular +ie.point %the FeyeF(/ !n the
coordinate system 2no.n as eye space%or view space(' the eye is located at the origin of the
coordinate system/ 9ollo.ing the standard con+ention' you orient the scene so the eye is loo2ing
do.n one direction of thez?a&is/ )he FupF direction is typically the positi+eydirection/
Dept of CS' CC ,age ;6
5/24/2018 Computer Graphics Q n A's
29/57
Computer Graphics and Visualization 10CS65
ye space' .hich is particularly useful for lighting' .ill -e discussed in Chapter 5/
T'e Vie Tran#f!r$
)he transform that con+erts .orld?space positions to eye?space positions is the view transform/
nce again' you e&press the +ie. transform .ith a & matri&/
)he typical +ie. transform com-ines a translation that mo+es the eye position in .orld space to
the origin of eye space and then rotates the eye appropriately/ 'G4Q94A)' 0' Vertices(L
glColor,ointer %>'G4Q94A)' 0' C48(L
2. Explain $!/elin& a "!l!r "%7e in /etail. (De"*+11, 1+
Dept of CS' CC ,age ;
5/24/2018 Computer Graphics Q n A's
30/57
Computer Graphics and Visualization 10CS65
An#5 e can use the +erte& list to define a color cu-e/ e can define a function *uad to dra.
*uadrilaterals polygons specified -y pointers into the +erte& list/ )he color cu-e specifies the si&
faces' ta2ing care to ma2e them all out.ard facing as follo.s/
G4floatVertices J=K J>K N OO?1/0' ?1/0' ?1/0P' O1/0' ?1/0' ?1/0P' O1/0' 1/0' ?1/0P' O?1/0' 1/0' ?1/0P O?
1/0' ?1/0' 1/0P' O1/0' ?1/0' 1/0P' O1/0' 1/0' 1/0P' O?1/0' 1/0' 1/0PPG4float color J=K J>K N OO0/0' 0/0' 0/0P' O1/0' 0/0' 0/0P' O1/0' 1/0' 0/0P' O0/0' 1/0' 0/0P' O0/0' 0/0'1/0P' O1/0' 0/0' 1/0P' O1/0' 1/0' 1/0P' O0/0' 1/0' 1/0PPL
+oid *uad %int a' int -' int c' int d(
O
glf+ %colorsJaK(L
glVerte&>f+%+erticesJaK(L
glcolor>f+%colorsJ-K(LglVerte&>f+%+erticesJ-K(L
glcolor>f+%colorsJcK(L
glVerte&>f+ %+erticesJcK(L
glcolor>f+ %colorsJdK(L
glVerte&>f+%+erticesJdK(L
glnd%(L
P
Void colorcu-e %(
O *uad %0'>';'1(L *uad
%;'>''6(L *uad
%0' ''>(L *uad
%1' ;' 6' 5(L *uad
%' 5' 6' (L *uad
%0' 1' 5' (L
. Explain affine tran#f!r$ati!n#. (De"*+11, 1+
An#5 An affine transformation is an important class of linear ;?D geometric transformations
.hich
maps +aria-les %e.g.pi&el intensity +alues located at position in an input image( into ne.
+aria-les %e.g. in an output image( -y applying a linear com-ination of translation'
rotation' scaling andHor shearing %i.e.non?uniform scaling in some directions( operations/
Dept of CS' CC ,age ;=
5/24/2018 Computer Graphics Q n A's
31/57
Computer Graphics and Visualization 10CS65
)he general affine transformation is commonly .ritten in homogeneous coordinates as sho.n-elo.:
5/24/2018 Computer Graphics Q n A's
32/57
Computer Graphics and Visualization 10CS65
)he origin %or displacement +ector(
)he -asis +ectors ? )he direction and distance for T1 mo+ement along each a&is
)his definition is relati+e
)o plot a point
5/24/2018 Computer Graphics Q n A's
33/57
Computer Graphics and Visualization 10CS65
UNIT 6
:EOETRIC OB)ECTS AND TRANSKORATIONS-II
1. Define an/ repre#ent t'e f!ll!in& *-D tran#f!r$ati!n# in '!$!&en!%# "!!r/inate
#y#te$.
a. Tran#lati!n
7. R!tati!n
". S"alin&
/. Refle"ti!n ()%n*+1*, 1*
Ans: Tran#lati!n
+oid gl)ranslateOfdP %)R, &' )R, y' )R, z(L
ultiplies the current matri& -y a matri& that mo+es %translates( an o-$ect -y the gi+en&' y' and z +alues
R!tati!n
+oid gl8otateOfdP%)R, angle' )R, &' )R, y' )R, z(L
ultiplies the current matri& -y a matri& that rotates an o-$ect in acountercloc2.ise direction a-out the ray from the origin through the point %&' y' z(/)he angle parameter specifies the angle of rotation in degrees/
S"alin& +oid glScaleOfdP %)R,&' )R, y' )R,z(L
ultiplies the current matri& -y a matri& that stretches' shrin2s' or reflects an o-$ect alongthe a&es/
Dept of CS' CC ,age >1
5/24/2018 Computer Graphics Q n A's
34/57
Computer Graphics and Visualization 10CS65
*uations :
)ranslation: ,f N ) T ,&fN &oT d&
yfN yoT dy
8otation: ,f N 8 ` ,
&fN &oM cos ? yoMsin
yfN &oM sin T yoMcos
Scale: ,f N S ` ,
&fN s& M &o
yfN sy M yo
*. 4'at i# "!n"atenati!n tran#f!r$ati!n= Explain r!tati!n a7!%t a fixe/ p!int. ()%n*+1*,
>
Ans: 8otate a house a-out the origin
8otate the house a-out one of its corners
translate so that a corner of the house is at the origin
rotate the house a-out the origin
translate so that the corner returns to its original position
Dept of CS' CC ,age >;
5/24/2018 Computer Graphics Q n A's
35/57
Computer Graphics and Visualization 10CS65
2. 4'at are J%aterni!n#= 4it' an exa$ple3 explain it# $at'e$ati"al repre#entati!n#.
(De"*+11, 1+
Ans: A *uaternion is an element of a dimensional +ector?space/ !t_s defined as . T &i T y$ T
z2 .here i' $ and 2 are imaginary num-ers/ Alternati+ely' a *uaternion is .hat you get .hen
you add a scalar and a >d +ector/ )he math -ehind *uaternions is only slightly harder than the
math -ehind +ectors/
void Camera::movex(float xmmod)
{
pos +=rotation *Vector3(xmmod,0.0f,0.0f);
void Camera::move!(float !mmod)
{
pos.!"=!mmod;
void Camera::move#(float #mmod)
{
pos +=rotation *Vector3(0.0f,0.0f, "#mmod);
void Camera::rotatex(float xrmod)
{
$%aternion nrot(Vector3(&.0f,0.0f,0.0f),xrmod *'V&0);rotation =rotation *nrot;
void Camera::rotate!(float !rmod)
{
$%aternion nrot(Vector3(0.0f,&.0f,0.0f),!rmod *'V&0);rotation =nrot *rotation;
void Camera::tic-(float seconds)
{if (xrot=0.0f)rotatex(xrot*seconds*rotspeed);
if (!rot=0.0f)rotate!(!rot*seconds*rotspeed);
if (xmov = 0.0f) movex(xmov * seconds * movespeed);
if (!mov = 0.0f) move!(!mov * seconds * movespeed);
if (#mov=0.0f)move#(#mov*seconds*movespeed);
Dept of CS' CC ,age >>
5/24/2018 Computer Graphics Q n A's
36/57
Computer Graphics and Visualization 10CS65
. Explain t'e 7a#i" tran#f!r$ati!n# in 2D an/ repre#ent t'e$ in $atrix f!r$. ()%n*+1+,
1+
Ans: )ranslation:
Scaling:
8otation:
6. 4'at are t'e a/0anta&e# !f J%aterni!n= ()%n*+1+, *
Ans: Zuaternions ha+e some ad+antages o+er other representations of rotations/
Zuaternions don_t suffer from gim-al loc2' unli2e uler angles/
)hey can -e represented as num-ers' in contrast to the W num-ers of a rotations matri&/
)he con+ersion to and from a&isHangle representation is tri+ial/
Smooth interpolation -et.een t.o *uaternions is easy %in contrast to a&isHangle or
rotation matrices(/
After a lot of calculations on *uaternions and matrices' rounding errors accumulate' so
you ha+e to normalize *uaternions and orthogonalize a rotation matri&' -ut normalizing a
*uaternion is a lot less trou-lesome than orthogonalizing a matri&/
Similar to rotation matrices' you can $ust multiply ; *uaternions together to recei+e a
*uaternion that represents -oth rotations/
Dept of CS' CC ,age >
5/24/2018 Computer Graphics Q n A's
37/57
Computer Graphics and Visualization 10CS65
UNIT -
VIE4IN:
1. 4it' neat #8et"'e#3 explain t'e 0ari!%# type# !f 0ie# t'at are e$pl!ye/ in "!$p%ter
&rap'i"# #y#te$#. ()%n*+1*, 1+
An#5
Per#pe"ti0e an/ parallel pr!e"ti!n# 5
,arallel +ie.ing is a limiting case of perspecti+e +ie.ing
,erspecti+e pro$ection has a C, .here all the pro$ector lines con+erge/
,arallel pro$ection has parallel pro$ectors/ ere the +ie.er is assumed to -e present atinfinity/ So here .e ha+e a Direction of pro$ection %D,(7 instead of center of
pro$ection%C,(/
Dept of CS' CC ,age >5
5/24/2018 Computer Graphics Q n A's
38/57
Computer Graphics and Visualization 10CS65
Ort'!&rap'i" Pr!e"ti!n# 5
,ro$ectors are perpendicular to the pro$ection plane/ ,ro$ection
plane is 2ept parallel to one of the principal faces/
A +ie.er needs more than ; +ie.s to +isualize .hat an o-$ect loo2s li2e from itsmulti+ie. orthographic pro$ection/
*. Briefly /i#"%## t'e f!ll!in& al!n& it' t'e f%n"ti!n# %#e/ f!r t'e p%rp!#e in !pen :L
i, Per#pe"ti0e pr!e"ti!n#
ii, Ort'!&!nal pr!e"ti!n# ()%n*+1*, 1+
An#5 i, ,erspecti+e pro$ection has a C, .here all the pro$ector lines con+erge/
T'e f!ll!in& f%n"ti!n# 'a0e t! 7e %#e/ t! "reate per#pe"ti0e pr!e"ti!n#5
Dept of CS' CC ,age >6
5/24/2018 Computer Graphics Q n A's
39/57
Computer Graphics and Visualization 10CS65
glatri&ode%G4Q,8C)!@(L
gl4oad!dentity%(L
glu,erspecti+e%f9V' fAspect ' f@ear,lane' f9ar,lane(L
Ort'!&!nal pr!e"ti!n#
,ro$ectors are perpendicular to the pro$ection plane/ ,ro$ection
plane is 2ept parallel to one of the principal faces/
A +ie.er needs more than ; +ie.s to +isualize .hat an o-$ect loo2s li2e from its multi+ie.orthographic pro$ection/
+oid glrtho% G4dou-le left'
G4dou-le right'
G4dou-le -ottom'
G4dou-le top'G4dou-le nearVal'
G4dou-le farVal(L
,arameters
left' right
Specify the coordinates for the left and right +ertical clipping planes/
-ottom' top
Specify the coordinates for the -ottom and top horizontal clipping planes/
nearVal' farVal
Specify the distances to the nearer and farther depth clipping planes/
)hese +alues are negati+e if the plane is to -e -ehind the +ie.er/
2. Explain t'e 0ari!%# type# !f ax!n!$etri" pr!e"ti!n#. (De"*+11, @
Dept of CS' CC ,age >
5/24/2018 Computer Graphics Q n A's
40/57
Computer Graphics and Visualization 10CS65
An#5 ,ro$ectors are orthogonal to the pro$ection plane ' -ut pro$ection plane can mo+e relati+e too-$ect/
Classification -y ho. many angles of a corner of a pro$ected cu-e are the same none: trimetric t.o: dimetric
three: isometric
. 4'at i# "an!ni"al 0ie 0!l%$e= Explain t'e $appin& !f a &i0en 0ie 0!l%$e t! t'e"an!ni"al f!r$. (De"*+11, @
An#5 )he diagram sho.s the normalization process
9irst the +ie. +olume specified -y the glortho function is mapped to the canonical form
Canonical 9orm : default +ie. +olume centerd at the origin and ha+ing sides of length ;/
)his in+ol+es ; steps :
3 o+e center to origin
)%?%leftTright(H;' ?%-ottomTtop(H;'%nearTfar(H;((3 Scale to ha+e sides of length ;
S%;H%left?right(';H%top?-ottom(';H%near?far((
)he resultant matri& is a product of the a-o+e ; matrices i/e/ , N S) N
;0 0
right left
right left right left
0;
0top ottom
top ottom top ottom0 0
; far near
near far far near 0 0 0 1
Dept of CS' CC ,age >=
5/24/2018 Computer Graphics Q n A's
41/57
Computer Graphics and Visualization 10CS65
6. Deri0e eJ%ati!n# f!r per#pe"ti0e pr!e"ti!n an/ /e#"ri7e t'e #pe"ifi"ati!n# !f aper#pe"ti0e "a$era 0ie in !pen :L. ()%n*+11, >
An#.5 )he ne. coordinate system is specified -y a translation androtation.ith respect to the old coordinate system:
+N 8 %+ ? +0( +0 is displacement+ector 8 is rotation matri&
8 may -e decomposed into
> rotations a-out the
coordinate a&es:
By $%ltiplyin& t'e 2 $atri"e# Rx3 Ry an/ R?3 !ne &et#
K!r f!r$%la $anip%lati!n#3 !ne trie# t! a0!i/ t'e tri&!n!$etri" f%n"ti!n#an/ ta8e#
@ote that the coefficients of 8 are constrained:
A rotation matri& is orthonormal: 8 8) N ! %unit matri&(
Dept of CS' CC ,age >W
5/24/2018 Computer Graphics Q n A's
42/57
Computer Graphics and Visualization 10CS65
UNIT @
LI:9TIN: AND S9ADIN:
1. Explain p'!n& li&'tin& $!/el. In/i"ate t'e a/0anta&e# an/ /i#a/0anta&e#. ()%n*+1*,
1+
An#5 ,hong de+eloped a simple model that can -e computed rapidly !t considers three components
3 Diffuse
3 Specular
3 Am-ient And #ses four +ectors
3 )o source represented -y the +ector l
3 )o +ie.er represented -y the +ector +
3 @ormal represented -y the +ector n
3 ,erfect reflector represented -y the +ector r
e need W coefficients to characterize the light source .ith am-ient' diffuse and specularcomponents/)he !llumination array for the ith
light source is gi+en -y the matri&:4ira 4iga 4i-a
4iN 4ird 4igd 4i-d
4irs 4igs 4i-s
)he intensity for each color source can -e computed -y adding the am-ient'specular and diffusecomponents/
/g/ 8ed intensity that .e see from source !:
!irN 8ira4iraT 8ird4irdT 8irs4irsN !raT!rdT!rs
Since the necessary computations are same for each light
source' ! N !aT!dT!s
*. 4'at are t'e /ifferent $et'!/# a0aila7le f!r #'a/in& a p!ly&!n= Briefly /i#"%## any *!f t'e$. ()%n*+1*, 1+
An#5 P!ly&!nal S'a/in&
Dept of CS' CC ,age 0
5/24/2018 Computer Graphics Q n A's
43/57
Computer Graphics and Visualization 10CS65
Klat #'a/in&
!n case of flat shading there are distinct -oundaries after color interpolation
> +ectors needed for shading are: l'n'+ /)he openG4 function to ena-le flat shading is :
glShadeodel%G4Q94A)(
9or a flat polygon'n is constant as the normal nis same at all points on the polygon/Also if .e
assume a distant +ie.er' the +ector 0is constant and if .e consider a distant light source then the
+ector l is also a constant/ere all the > +ectors are constant and therefore the shading
calculations needs to -e done only once for an entire polygon and each point on the polygon is
assigned the same shade/ )his techni*ue is 2no.n as 9lat shading/
Disad+antage :
5/24/2018 Computer Graphics Q n A's
44/57
Computer Graphics and Visualization 10CS65
O
glClearColor%1/0'1/0'1/0'1/0(L
glColor>f%1/0'0/0'0/0(L
gl,ointSize%5/0(L
glatri&ode%G4Q,8C)!@(L
gl4oad!dentity%(L
glurtho;D%0/0'WW/0'0/0'WW/0(L
glut,ost8edisplay%(L HH re*uest redisplay
P
+oid display%+oid(
O
HM clear .indo. MH
glClear%G4QC48QglColor>f%0/0' 0/0' 1/0(L HH set color to -lueHM dra. rectangles MH
for%iN0Lima&&LiTT(
&JiKN&0TiMd&L HH compute &JiK
for%$N0L$ma&yL$TT(
yJ$KNy0T$MdyL HH compute yJiK
glColor>f%0/0' 0/0' 1/0(L
for%iN0Lima&&?1LiTT(
for%$N0L$ma&y?1L$TT(
O
glColor>f%0/0' 0/0' 1/0(Lgl
5/24/2018 Computer Graphics Q n A's
45/57
Computer Graphics and Visualization 10CS65
glut!nitDisplayode%G4#)QS!@G4 U G4#)Q8G
5/24/2018 Computer Graphics Q n A's
46/57
Computer Graphics and Visualization 10CS65
/* ec%rsive s%division of tetra1edron (C1apter 2). 1reedispla! modes: 4ire frame, constant, and interpolative s1adin5 */
/*'ro5ram also ill%strates definin5 materials and li51tso%rces in m!iit() */
/* mode 0 = 4ire frame, mode & = constants1adin5, mode 6 = interpolative s1adin5 */
/* 7pdated ctoer &2, 6000, ! Car! 8axer to convert / to C++. */
9incl%de stdli.19incl%de mat1.19incl%de iostream9incl%de ;
/* initial tetra1edron */
point v>={{0.0, 0.0, &.0, {0.0, 0.?@60?, "0.33333,
{"0.&2@?A, "0.@A&@0B, "0.333333, {0.&2@?A, "0.@A&@0B," 0.333333;
static = {0.0,0.0,0.0;
int n;int mode;
void trian5le (point a, point , pointc); void normal (point p);
void dividetrian5le (point a, point , point c, intm); void tetra1edron (int m);void displa! (void);
void m!es1ape (int 4, int1); void m!init ();
%sin5 namespace std;
void main(int ar5c, c1ar **ar5v){
co%t Dnter n%mer of levels of rec%rsion:D; cin n;5l%tnit (Ear5c, ar5v);
5l%tnitFispla!Gode (
5/24/2018 Computer Graphics Q n A's
47/57
Computer Graphics and Visualization 10CS65
{
if (mode==0) 5lHe5in(; d=sPrt(d);if(d0.0) for(i=0; i3; i++) pi>/=d;
void dividetrian5le (point a, point , point c, intm) /* trian5le s%division %sin5 vertex n%mersri51t1and r%le applied to create o%t4ard pointin5 faces */{
point v&, v6,v3; int Q;if(m0){
for(Q=0; Q3; Q++) v&Q>=aQ>+Q>; normal(v&);
for(Q=0; Q3; Q++) v6Q>=aQ>+cQ>; normal(v6);
for(Q=0; Q3; Q++) v3Q>=Q>+cQ>; normal(v3);dividetrian5le (a, v&, v6, m"&);dividetrian5le (c, v6, v3, m"&);dividetrian5le (, v3, v&, m"&);dividetrian5le (v&, v3, v6, m"&);
else
trian5le (a,,c); /* dra4 trian5le at end of rec%rsion */
void tetra1edron (int m)/* Rppl! trian5le s%division to faces of tetra1edron */{
dividetrian5le (v0>, v&>, v6>, m);dividetrian5le (v3>, v6>, v&>, m);dividetrian5le (v0>, v3>, v&>, m);dividetrian5le (v0>, v6>, v3>, m);
void displa! (void)/* Fispla!s all t1ree modes, side ! side */{
Dept of CS' CC ,age 5
5/24/2018 Computer Graphics Q n A's
48/57
Computer Graphics and Visualization 10CS65
5lClear (
5/24/2018 Computer Graphics Q n A's
49/57
Computer Graphics and Visualization 10CS65
UNIT ->
IPLEENTATION
1. Di#"%## t'e Bre#en'a$M# ra#teri?ati!n al&!rit'$. 9! i# it a/0anta&e!%# 'en
"!$pare/ t! !t'er exi#tin& $et'!/#= De#"ri7e. ()%n*+1*, 1+
An#5 Consider dra.ing a line on a raster grid .here .e restrict the allo.a-le slopes of the line to
the range /
!f .e further restrict the line?dra.ing routine so that it al.ays incrementsxas it plots' it -ecomes
clear that' ha+ing plotted a point at !x"y#' the routine has a se+erely limited range of options as to
.here it may put the nextpoint on the line:
!t may plot the point !x$%"y#' or:
!t may plot the point !x$%"y$%#/
So' .or2ing in thefirst positive octantof the plane' line dra.ing -ecomes a matter of deciding-et.een t.o possi-ilities at each step/
e can dra. a diagram of the situation .hich the plotting program finds itself in ha+ing plotted
!x"y#/
!n plotting !x"y#the line dra.ing routine .ill' in general' -e ma2ing a compromise -et.een .hat it
.ould li2e to dra. and .hat the resolution of the screen actually allo.s it to dra./ #sually the
plotted point !x"y#.ill -e in error' the actual' mathematical point on the line .ill not -e addressa-le
on the pi&el grid/ So .e associate an error' ' .ith eachyordinate' the real +alue of
y should -e / )his error .ill range from ?0/5 to $ust under T0/5/
Dept of CS' CC ,age
5/24/2018 Computer Graphics Q n A's
50/57
Computer Graphics and Visualization 10CS65
!n mo+ing from x to x$%.e increase the +alue of the true %mathematical( y?ordinate -y an
amount e*ual to the slope of the line' m/ e .ill choose to plot !x$%"y#if the difference -et.een
this ne. +alue andyis less than 0/5/
ther.ise .e .ill plot !x$%"y$%#/ !t should -e clear that -y so doing .e minimise the total error-et.een the mathematical line segment and .hat actually gets dra.n on the display/
)he error resulting from this ne. point can no. -e .ritten -ac2 into ' this .ill allo. us to
repeat the .hole process for the ne&t point along the line' at x$&/
)he ne. +alue of error can adopt one of t.o possi-le +alues' depending on .hat ne. point isplotted/ !f !x$%"y#is chosen' the ne. +alue of error is gi+en -y:
ther.ise it is:
)his gi+es an algorithm for a DDA .hich a+oids rounding operations' instead using the error
+aria-le to control plotting:
)his still employs floating point +alues/ Consider' ho.e+er' .hat happens if .e multiply across
-oth sides of the plotting test -y and then -y ;:
Dept of CS' CC ,age =
5/24/2018 Computer Graphics Q n A's
51/57
Computer Graphics and Visualization 10CS65
All *uantities in this ine*uality are no. integral/
Su-stitute for / )he test -ecomes:
)his gi+es an integer-onlytest for deciding .hich point to plot/
)he update rules for the error on each step may also -e cast into form/ Consider the floating?
point +ersions of the update rules:
ultiplying through -y yields:
.hich is in form/
#sing this ne. bberror__ +alue' ' .ith the ne. test and update e*uations gi+es
5/24/2018 Computer Graphics Q n A's
52/57
Computer Graphics and Visualization 10CS65
!nteger only ? hence efficient %fast(/
ultiplication -y ; can -e implemented -y left?shift/
)his +ersion limited to slopes in the first octant' /
*. Explain t'e "!'en-#%t'erlan/ line "lippin& al&!rit'$ in /etail. ()%n*+1*, 1+
An#5
5/24/2018 Computer Graphics Q n A's
53/57
Computer Graphics and Visualization 10CS65
!f .e further restrict the line?dra.ing routine so that it al.ays incrementsxas it plots' it -ecomes
clear that' ha+ing plotted a point at !x"y#' the routine has a se+erely limited range of options as to
.here it may put the nextpoint on the line:
!t may plot the point !x$%"y#' or:
!t may plot the point !x$%"y$%#/
So' .or2ing in thefirst positive octantof the plane' line dra.ing -ecomes a matter of deciding-et.een t.o possi-ilities at each step/
e can dra. a diagram of the situation .hich the plotting program finds itself in ha+ing plotted
!x"y#/
!n plotting !x"y#the line dra.ing routine .ill' in general' -e ma2ing a compromise -et.een .hat
it .ould li2e to dra. and .hat the resolution of the screen actually allo.s it to dra./ #sually theplotted point !x"y#.ill -e in error' the actual' mathematical point on the line .ill not -e
addressa-le on the pi&el grid/ So .e associate an error' ' .ith eachyordinate' the real +alue of
y should -e / )his error .ill range from ?0/5 to $ust under T0/5/
!n mo+ing from x to x$%.e increase the +alue of the true %mathematical( y?ordinate -y an
amount e*ual to the slope of the line' m/ e .ill choose to plot !x$%"y#if the difference -et.een
this ne. +alue andyis less than 0/5/
ther.ise .e .ill plot !x$%"y$%#/ !t should -e clear that -y so doing .e minimise the total error-et.een the mathematical line segment and .hat actually gets dra.n on the display/
)he error resulting from this ne. point can no. -e .ritten -ac2 into ' this .ill allo. us to
repeat the .hole process for the ne&t point along the line' at x$&/
Dept of CS' CC ,age 51
5/24/2018 Computer Graphics Q n A's
54/57
Computer Graphics and Visualization 10CS65
)he ne. +alue of error can adopt one of t.o possi-le +alues' depending on .hat ne. point isplotted/ !f !x$%"y#is chosen' the ne. +alue of error is gi+en -y:
ther.ise it is:
)his gi+es an algorithm for a DDA .hich a+oids rounding operations' instead using the error
+aria-le to control plotting:
)his still employs floating point +alues/ Consider' ho.e+er' .hat happens if .e multiply across
-oth sides of the plotting test -y and then -y ;:
All *uantities in this ine*uality are no. integral/
Su-stitute for / )he test -ecomes:
)his gi+es an integer-onlytest for deciding .hich point to plot/
)he update rules for the error on each step may also -e cast into form/ Consider the floating?
point +ersions of the update rules:
Dept of CS' CC ,age 5;
5/24/2018 Computer Graphics Q n A's
55/57
Computer Graphics and Visualization 10CS65
ultiplying through -y yields:
.hich is in form/
#sing this ne. bberror__ +alue' ' .ith the ne. test and update e*uations gi+es
5/24/2018 Computer Graphics Q n A's
56/57
Computer Graphics and Visualization 10CS65
intersecting lines' -oth aliased and antialiased/ )he pictures ha+e -een magnified to sho. the
effect/
6. Explain Lian& Bar#8y line "lippin& al&!rit'$ in /etail. ()%n*+1+, 1+
Ans:
Dept of CS' CC ,age 5
5/24/2018 Computer Graphics Q n A's
57/57
Computer Graphics and Visualization 10CS65
Dept of CSE, CEC Page 55