Computer Graphics Q n A's

of 57

  • date post

    14-Oct-2015
  • Category

    Documents

  • view

    3.285
  • download

    0

Embed Size (px)

description

Computer Graphics Q n A's for VTU 6th sem CSE.

Transcript of Computer Graphics Q n A's

  • 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

    glutDispla