Zeal Polytechnic, Pune.: Second Year (Sy) Diploma in Computer Engineering Scheme: I Semester: Iii

Download as pdf or txt
Download as pdf or txt
You are on page 1of 59

Zeal Education Society’s

ZEAL POLYTECHNIC, PUNE.


NARHE │PUNE -41 │ INDIA

SECOND YEAR (SY)


DIPLOMA IN COMPUTER ENGINEERING
SCHEME: I SEMESTER: III

NAME OF SUBJECT: COMPUTER GRAPHICS


Subject Code: 22318

MSBTE QUESTION PAPERS & MODEL ANSWERS


1. MSBTE WINTER-18 EXAMINATION
2. MSBTE SUMMER-19 EXAMINATION
3. MSBTE WINTER-19 EXAMINATION

Page 1 of 10
11819
22318
3 Hours / 70 Marks Seat No.

Instructions : (1) All Questions are compulsory.


(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data, if necessary.

Marks
1. Attempt any FIVE of the following : 10
(a) Define :
(i) Pixel
(ii) Frame Buffer
(b) Give the characteristics of display adaptor.
(c) Explain Raster Scan.
(d) State two line drawing algorithms.
(e) List types of Polygon.
(f) List various polygon filling algorithms.
(g) Give matrix representation for 2D scaling.

2. Attempt any THREE of the following : 12


(a) Differentiate between Random Scan and Raster Scan.
(b) Explain and write steps for DDA line drawing algorithm.
(c) List out basic transformations techniques. Explain scaling transformation with
respect to 2D.
(d) Explain differ types of Text clipping in brief.

[1 of 2] P.T.O.
22318 [2 of 2]
3. Attempt any THREE of the following : 12
(a) Explain stroke method and Bitmap method with example.
(b) Explain types of Parallel Projection with example.
(c) Write down Cohen-Sutherland Line clipping algorithm.
(d) Explain Koch curve with diagram.

4. Attempt any THREE of the following : 12


(a) Compare Bitmap Graphics and Vector based graphics.
(b) Consider line from (4, 4) to (12, 9). Use Bresenhaum’s algorithm to rasterize
this line.
(c) Use Cohen-Sutherland algorithm to clip two lines P1 (40, 15) – P2 (75, 45)
and P3(70, 20) – P4(100, 10) against a window A(50, 10), B(80, 10),
C(80, 40) & D(50, 40)
(d) Consider the square A(1, 0), B(0, 0), C(0, 1), D(1, 1). Rotate the square
ABCD by 45 anticlockwise about point A(1, 0).
(e) Explain curve generation using Interpolation technique.

5. Attempt any TWO of the following : 12


(a) Rotate a triangle defined by A(0, 0), B(6, 0) & C(3, 3) by 90 about origin in
anti-clockwise direction.
(b) Explain boundary fill algorithm with pseudo-code. Also mention its
limitations, if any.
(c) Obtain the curve parameters for drawing a smooth Bezier curve for the
following points A(0, 10), B(10, 50), C(70, 40) & D(70, –20).

6. Attempt any TWO of the following : 12


(a) Write matrices in homogeneous co-ordinate system for 3D scaling
transformation.
(b) Write down Cyrus-Beck line clipping algorithm.
(c) Derive the expression for decision parameter used in Bresenhaum’s circle
drawing algorithm.
_______________
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER– 18 EXAMINATION

Subject Name: Computer Graphics Model Answer Subject Code: 22318


Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the model answer
scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not
applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The
figures drawn by candidate and model answer may vary. The examiner may give credit for any equivalent
figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values
may vary and there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer
based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent
concept.

Q. Sub Answer Marking


No Q. Scheme
. N.

1 Attempt any FIVE of the following: 10 M

a Define: 2M

(i)Pixel

(ii)Frame Buffer

Ans  Pixel 1 M each for


correct
Pixel or Pel is defined as "the smallest addressable screen element". definition
OR

A pixel may be defined as the smallest size object or color spot that can
be displayed and addressed on a monitor.

 Frame Buffer

The frame buffer is the video memory (RAM) that is used to hold or
map the image displayed on the screen.

OR

A framebuffer (frame buffer, or sometimes framestore) is a portion


of RAM containing a bitmap that drives a video display.

Page 1 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
b Give the characteristics of display adaptor. 2M

Ans The characteristics of common display adapters are given in Table. The 2M for any
present-day display adapter supports all the modes of the preceding display relevant
adapters characteristi
cs

c Explain Raster Scan 2M

Ans  In Raster scan, the electron beam from electron gun is swept horizontally 2 M for
across the phosphor one row at time from top to bottom. correct
 The electron beam sweeps back and forth from left to right across the explanation
screen. The beam is on, while it moves from left to right. The beam is off,
when it moves back from right to left. This phenomenon is called the
horizontal retrace.
 As soon as the beam reaches the bottom of the screen, it is turned off and is
rapidly retraced back to the top to start again. This is called the vertical
retrace.
 Raster scan displays maintain the steady image on the screen by repeating
scanning of the same image. This process is known as refreshing of screen.

Raster Scan CRT

d State two line drawing algorithms. 2M

Ans Digital Differential Analyzer (DDA) Algorithm 1 M for each


Algorithm
Digital Differential Analyzer algorithm generates a line from differential equations of line
Page 2 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
and hence the name DDA.

Bresenham’s Algorithm

The Bresenham algorithm is another line drawing algorithm which uses integer calculations
for drawing line.

e List types of Polygon 2M

Ans Polygon can be of two types:- 1 M each

 Convex polygon

 Concave polygon

f List various polygon filling algorithms 2M

Ans Various polygon filling algorithms are: 1 M each,


Any two
 Flood Fill Algorithm

 Boundary Fill Algorithm

 Scan Line Algorithm

g Give matrix representation for 2D scaling 2M

Ans Let us assume that the original co-ordinates are (X, Y), the scaling factors are (SX, SY), and
2 M for
proper
the produced co-ordinates are (X', Y'). This can be mathematically represented as shown Matrix
below:
X'=X  SX and Y' = Y  SY
The scaling factor SX, SY scales the object in X and Y direction respectively. The above
equations can also be represented in matrix form as below:
 X'   X   Sx 0 
  =   
 Y'   Y   0 Sy 

2 Attempt any THREE of the following: 12 M

a Differentiate between Random Scan and Raster Scan. 4M

Ans Random Scan Display Raster Scan Display Any four


In vector scan display the beam is In raster scan display the beam is points: 1
moved between the end points of themoved all over the screen one scan at mark each
graphics primitives. a time, from top to bottom and then
back to top.
Vector display flickers when the In raster display, the refresh process
number of primitives in the buffer is independent of the complexity of
becomes too large. the image.

Page 3 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Scan conversion is not required. Graphics primitives are specified in
terms of their endpoints and must be
scan converted into their
corresponding pixels in the frame
buffer.
Scan conversion hardware is not Because each primitive must be scan
required. converted real time dynamics is far
more computational and requires
separate scan conversion hardware.
Vector display draws continuous and Raster display can display
smooth lines. mathematically smooth lines,
polygons and boundaries of curves
primitives only by approximating
them with pixels on the raster grid.
Mathematical functions are used to Screen points/pixels are used to draw
draw an image. an image.
It does not user interlacing. It uses interlacing.
Editing is easy. Editing is difficult.
Cost is more Cost is low
Vector display only draws lines and Raster display has ability to display
characters. areas filled with solid colors or
patterns.
Resolution is good because this system Resolution is poor because raster
produces smooth lines drawings system in contrast produces zigzag
because CRT beam directly follows the lines that are plotted as discrete point
line path. sets.
Picture definition is stored as a set of Picture definition is stored as a set of
line drawing instructions in a display intensity values for all screen points,
file. called pixels in a refresh buffer area.
They are more suited to line drawing They are more suited to geometric
application e.g. CRO and pen plotter. area drawing applications e.g.
monitors, TV
It uses beam-penetration method. It uses shadow-mask method
b Explain and write steps for DDA line drawing algorithm. 4M

Ans  This algorithm generates a line from differential equations of line and Explanation
hence the name DDA. 2M,
Algorithm
 DDA algorithm is an incremental scan conversion method.
2M
 A DDA is hardware or software used for linear interpolation of variables
over an interval between start and end point.
 DDAs are used for rasterization of lines, triangles and polygons.
 DDA method is referred by this name because this method is very similar
to the numerical differential equations. The DDA is a mechanical device
that solves differential equations by numerical methods.

Algorithm:

Steps 1: Read the end points of line (x1,y1) and (x2,y2).


Page 4 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Steps 2: x = abs (x2 – x1) and
y = abs (y2 – y1)
Step 3: if x  y then
length = x
else
length = y
end if
Step 4: x = (x2 – x1)/length
Step 5: y = (y2 – y1)/length
Step 6: x= x1 + 0.5 * sign (x)
y= y1 + 0.5 * sign (y)
Step 7: i = 1
while (i  length)
{
plot (integer (x), integer (y))
x = x + x
y = y + y
i=i+1
}
Step 8: End
c List out basic transformation techniques. Explain scaling transformation with respect to 4M
2D.

Ans Basic transformations techniques are: Listing 1M,


Explanation
 Translation 3M

 Scaling

 Rotation

Scaling Transformation

 Scaling means to change the size of object. This change can either
be positive or negative.
 To change the size of an object, scaling transformation is used. In
the scaling process, you either expand or compress the dimensions of the
object.
 Scaling can be achieved by multiplying the original co-ordinates of
the object with the scaling factor to get the desired result.
 Let us assume that the original co-ordinates are (X, Y), the scaling
factors are (SX, SY), and the produced co-ordinates are (X', Y'). This can be
mathematically represented as shown below:
X'=X  SX and Y' = Y  SY
 The scaling factor SX, SY scales the object in X and Y direction
Page 5 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
respectively. The above equations can also be represented in matrix form as
below:
 X'   X   Sx 0 
  =   
 Y'   Y   0 Sy 
OR
P'=P  S
Where, S is the scaling matrix.

(a) Before Scaling (b) After Scaling

 If we provide values less than 1 to the scaling factor S, then we can reduce
the size of the object. If we provide values greater than 1, then we can
increase the size of the object.

d Explain differ types of Text clipping in brief. 4M

Ans Many techniques are used to provide text clipping in a computer graphics. It depends on the Explanation
methods used to generate characters and the requirements of a particular application. There of 3 methods
are three methods for text clipping which are listed below − with
1) All or none string clipping diagrams 4
2) All or none character clipping marks
3) Text clipping

The following figure shows all or none string clipping −

Page 6 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

In all or none string clipping method, either we keep the entire string or we
reject entire string based on the clipping window. As shown in the above
figure, Hello2 is entirely inside the clipping window so we keep it and Hello1
being only partially inside the window, we reject.
The following figure shows all or none character clipping –

This clipping method is based on characters rather than entire string. In this
method if the string is entirely inside the clipping window, then we keep it. If it
is partially outside the window, then −
You reject only the portion of the string being outside
If the character is on the boundary of the clipping window, then we discard that
entire character and keep the rest string.
The following figure shows text clipping –

This clipping method is based on characters rather than the entire string. In this
method if the string is entirely inside the clipping window, then we keep it. If it
is partially outside the window, then you reject only the portion of string being

Page 7 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
outside. If the character is on the boundary of the clipping window, then we
discard only that portion of character that is outside of the clipping window.
3 Attempt any THREE of the following: 12 M

a Explain stroke method and Bitmap method with example. 4M

Ans 1)STROKE METHOD Stroke


Method 2
 Stroke method is based on natural method of text written by human being. In this method Marks;
graph is drawing in the form of line by line. Bitmap
Method 2
 Line drawing algorithm DDA follows this method for line drawing. Marks
 This method uses small line segments to generate a character. The small series of line
segments are drawn like a stroke of pen to form a character.
 We can build our own stroke method character generator by calls to the line drawing
algorithm. Here it is necessary to decide which line segments are needed for each
character and then drawing these segments using line drawing algorithm.

2)BITMAP METHOD

 Bitmap method is a called dot-matrix method as the name suggests this method use array
of bits for generating a character. These dots are the points for array whose size is
fixed.
 In bitmatrix method when the dots is stored in the form of array the value 1 in array
represent the characters i.e. where the dots appear we represent that position with
numerical value 1 and the value where dots are not present is represented by 0 in array.
 It is also called dot matrix because in this method characters are represented by an array
of dots in the matrix form. It is a two dimensional array having columns and rows.
 A 5x7 array is commonly used to represent characters. However 7x9 and 9x13 arrays are
also used. Higher resolution devices such as inkjet printer or laser printer may use
character arrays that are over 100x100.
b Explain types of Parallel Projection with example. 4M

Ans  Orthographic projection – the projection direction is a normal one to the plane and it is Orthographi
categorized as c projection
2 marks;
o Top projection
Oblique
o Front projection projection 2
o Side projection Marks

Page 8 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

 Oblique projection – the projection direction is not a normal one to the plane; it gives a
better view and it is categorized as
o Cavalier projection
o Cabinet projection

c Write down Cohen-Sutherland Line clipping algorithm. 4M

Ans Step 1: Scan end points for the line P1(x1, y1) and P2(x2, y2) Correct
algorithm 4
Step 2: Scan corners for the window as (Wx1, Wy1) and (Wx2, Wy2) Marks

Step 3: Assign the region codes for endpoints P1 and P2 by

Bit 1 - if (x < Wx1)

Bit 2 - if (x < Wx2)

Bit 3 - if (x < Wy2)

Page 9 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Bit 4 - if (x < Wy1)

Step 4: Check for visibility of line P1, P2

 If region codes for both end points are zero then the line is visible, draw it and jump to
step 9.
 If region codes for end points are not zero and the logical and operation of
them is also not zero then the line is invisible, reject it and jump to step 9.
 If region codes for end points does not satisfies the condition in 4(i) and 4(ii)
then line is partly visible.
Step 5: Determine the intersecting edge of the clipping window by inspecting the
region codes for endpoints.

 If region codes for both the end points are non-zero, find intersection points P1
and P2 with boundary edges of clipping window with respect to point P1 and P2.
 If region code for any one end point is non zero then find intersection point P1
or P2 with the boundary edge of the clipping window with respect to it.
Step 6: Divide the line segments by considering intersection points.

Step 7: Reject the line segment if any of the end point of it appear outside the window.

Step 8: Draw the remaining line.

Step 9: Exit

d Explain Koch curve with diagram. 4M

Ans Koch Curve: - In Koch curve, begin at a line segment. Divide it into third and replace the Description
3 Marks;
center by the two adjacent sides of an equilateral triangle as shown below.
Diagram 1
Mark

This will give the curve which starts and ends at same place as the original segment but is
built of 4 equal length segments, with each 1/3rd of the original length. So the new curve
has 4/3 the length of original segments. Repeat same process for each of the 4 segment
which will give curve more wiggles and its length become 16/9 times the original.
Suppose repeating the replacements indefinitely, since each repetition increases the length
by a factor of 4/3, the length of the curve will be infinite but it is folded in lots of tiny

Page 10 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
wiggles.

4 Attempt any THREE of the following: 12 M

a Compare Bitmap Graphics and Vector based graphics. 4M

Ans Bitmap Graphics Vector Based Graphic Any 4


Points of
comparison;
It is pixel based image It is Mathematical based image
1 Mark each
Images are resolution dependent. Images are formula based /
dependent.

These images are not easily Easily scalable with the help of
scalable. formula.

Poor quality of image as oppose Better image quality as compare to


to Vector based Graphics. Bitmap Graphics.

Size of image is high. Size of image is low.

b Consider line from (4, 4) to (12 9). Use Bresenham's algorithm to rasterize this line. 4M

Ans x1 = 4 | y1 = 4 | & | x2 = 12 | y2 = 9 Any


Suitable
Calculation Result method can
be consider
dx = abs(x1 - x2) 8 = abs(4 - 12)
Correct
dy = abs(y1 - y2) 5 = abs(4 - 9) steps and
result: 4
p = 2 * (dy - dx) -6 = 2 * (5 - 8) Marks

ELSE x = x1 | y = y1 | end = x2

x = 4 | y = 4 | end = 12

STEP while(x < x=x+1 if(p < 0) { p = p + 2 * dy OUTPUT


end) } else{ p = p + 2 *
(dy - dx) }

1 5 < 12 5=4+1 IF 4 = -6 + 2 * 5 x=5|y=4

2 6 < 12 6=5+1 ELSE -2 = 4 + 2 * (5 - 8) x=6|y=5

3 7 < 12 7=6+1 IF 8 = -2 + 2 * 5 x=7|y=5

Page 11 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
4 8 < 12 8=7+1 ELSE 2 = 8 + 2 * (5 - 8) x=8|y=6

5 9 < 12 9=8+1 ELSE -4 = 2 + 2 * (5 - 8) x=9|y=7

6 10 < 12 10 = 9 + 1 IF 6 = -4 + 2 * 5 x = 10 | y = 7

7 11 < 12 11 = 10 + 1 ELSE 0 = 6 + 2 * (5 - 8) x = 11 | y = 8

8 12 < 12 12 = 11 + 1 ELSE -6 = 0 + 2 * (5 - 8) x = 12 | y = 9

c Use Cohen-Sutherland algorithm to clip two lines PI (40, 15) -- P2 (75. 45) and P3 4 M
(70, 20) — P4 (100, 10) against a window A (50, 10), B (80, 10). C(80, 40) &
D(50,40)
Ans Solution : Any
suitable
Line 1 : P1 (40, 15) - P2 (75, 45) Wxi = 50 Wy2 = 40 Wx2 = 80 Wy2 = 10 method can
be consider
Point Endeode ANDing Computatio
n for Line
P1 0001 0000 (Partially visible) 1: 2 Marks;
Computatio
P2 0000 n for Line 2
: 2 Marks

y1 = m(xL – x ) + y = (50-40)+15 m=

= 23.57

x1 = (yT – y ) + x = (40-50)+40 = 69.16

y2 = m(xR – x ) + y = (80-40)+15 = 49.28

x2 = (yB – y ) + x = (10-15)+40 = 34.16

Hence:

Page 12 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Line 2 : P3 (70,20) – P4 (100,10) Wxi = 50 Wy2 = 40 Wx2 = 80 Wy2 = 10

Point Endeode ANDing

P3 0000 0000 (Partially visible)

P4 0010

Slope m`= = =

y`1 = m(xL – x ) + y = (50-70)+20 = 26.66

x`1 = (yT – y ) + x = - 3 (40-20)+70 = 10

y`2 = m(xR – x ) + y = (80-70)+20 = 16.66

x`2 = (yB – y ) + x = - 3 (10-20)+70 = 100

Hence:

d Consider the square A (1, 0), B (0, 0), C (O, 1), D (1, I). Rotate the square ABCD by 4 M
45° anticlockwise about point A (1. 0).
Ans Matrix
formation 2
Marks;
Matrix
calculation
2 Marks
Here,  = 45°, Xp =1 Yp = 0

[T1.R.T2 ]=

Page 13 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

e Explain curve generation using Interpolation technique. 4M

Ans Specify a spline curve by giving a set of coordinate positions, called control points, Description
which indicates the general shape of the curve These, control points are then fitted 2 Marks;
with piecewise continuous parametric polynomial functions in one of two ways. Example/Di
agram 2
When polynomial sections are fitted so that the curve passes through each control
Marks
point, the resulting curve is said to interpolate the set of control points. On the other
hand, when the polynomials are fitted to the general control-point path without
necessarily passing through any control point, the resulting curve is said to
approximate the set of control points interpolation curves are commonly used to
digitize drawings or to specify animation paths. Approximation curves are primarily
used as design tools to structure object surfaces an approximation spline surface
credited for a design application. Straight lines connect the control-point positions
above the surface.

Page 14 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
5 Attempt any two of the following: 12 M

a Rotate a triangle defined by A(0,0), B(6,0), & C(3,3) by 900 about origin in anti-clock wise direction 6M

Ans The new position of point A (0, 0) will become A' (0,0) Matrix 2
The new position of point B (6,0) will become B' (0, 6) Marks
The new position of point C (3, 3) will become C' (-3, 3)
Correct
 x'   x   cos  –sin  0  answer 4
 y' =  y  x  sin  cos  0
 marks
     
 '   1   0 0 1

0 0 1 0 1 0
6 0 1 x -1 0 0
3 3 1 0 0 1

0 0 1
= 0 6 1
-3 3 1

b Explain boundary fill algorithm with pseudo code. Also mention its limitations if any. 6M

Ans 4m
algorithm,
2m for
limitations

Limitations:
 There is a problem with this technique. Consider the case following, where we tried to fill the

Page 15 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
entire region. Here, the image is filled only partially. In such cases, 4-connected pixels technique
cannot be used.

c obtain the curve parameters for drawing a smooth Bezier curve for the following points A(0,10), 6M
B(10,50), C(70,40) &D(70,-20)

Page 16 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Any correct
method can
be consider.

Calculation
3 Marks

Diagram
3Marks

Page 17 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Page 18 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

OR
ITERATION 1:

Mid of AB = AB’

AB’ = [(Ax + Bx)/2, (Ay + By)/2)]

= [(0+10)/2, (10+50)/2]

= [(10)/2, (60)/2]

= (5, 30)

Mid of BC = BC’

BC’ = [(Bx + Cx)/2, (By + Cy)/2)]

= [(10+70)/2, (50+40)/2]

= [(80)/2, (90)/2]

= (40, 45)

Mid of CD = CD’

CD’ = [(Cx + Dx)/2, (Cy + Dy)/2)]

= [(70+70)/2, (40+(-20))/2]

Page 19 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
= [(140)/2, (20)/2]

= (70, 10)

ITERATION 2:

Mid of ABC = ABC’

ABC’ = [(ABx + BCx)/2, (ABy + BCy)/2)]

= [(5+40)/2, (30+45)/2]

= [(45)/2, (75)/2]

= (22.5, 37.5)

Mid of BCD = BCD’

BCD’ = [(BCx + CDx)/2, (BCy + CDy)/2)]

= [(40+70)/2, (45+10)/2]

= [(110)/2, (55)/2]

= (55, 27.5)

ITERATION 3:

Mid of ABCD = ABCD’

ABCD’ = [(ABCx + BCDx)/2, (ABCy + BCDy)/2)]

= [(22.5+55)/2, (37.5+27.5)/2]

= [(77.5)/2, (65)/2]

= (38.25, 32.5)

Page 20 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

6 Attempt any two of the following: 12 M

a Write matrices in homogeneous co-ordinates system for 3D scaling transformation. 6M

Ans 3D transformation matrix for scaling is as follows: Correct


matrix 6
0 
Sx 0 0 0
Marks

S=
 Sy 0 0 
0 0 Sz 0
0 0 0 1
Page 21 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
It specifies three co-ordinates with their own scaling factors. If scale factors,
Sx = Sy = Sz = S > 1 then the scaling is called as
magnification.
Sx = Sy = Sz = S < 1 then the scaling is called as
reduction.
Therefore, point after scaling with respect to origin can be calculated as,
 P=P  S

b Write down Cyrus-Beck line clipping algorithm. 6M

Ans Step 1: Read end points of line P1 and P2. Correct


Step 2: Read vertex coordinates of clipping window. algorithm 6
marks
Step 3: Calculate D = P2 – P1.
Step 4: Assign boundary point b with particular edge.
Step 5: Find inner normal vector for corresponding edge.
Step 6:Calculate D.n and W = P1 – b
Step 7:If D.n > 0
tL = – (W.n)/(D.n)
else
tU = – (W.n)/(D.n)
end if
Step 8: Repeat steps 4 through 7 for each edge of clipping window.
Step 9: Find maximum lower limit and minimum upper limit.
Step 10: If maximum lower limit and minimum upper limit do not satisfy
condition 0 ≤ t ≤ 1 then ignore line.
Step 11: Calculate intersection points by substituting values of maximum lower
limit and minimum upper limit in parametric equation of line P1P2.
Step 12: Draw line segment P(tL) to P(tU).
Step 13: Stop.
c Derive the expression for decision parameter used in Bresenhaum’s circle drawing algorithm. 6M

Page 22 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Correct
method and
correct
equation 6
Marks

Page 23 of 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Page 24 of 24
21819
22318
3 Hours / 70 Marks Seat No.

Instructions : (1) All Questions are compulsory.

(2) Answer each next main Question on a new page.

(3) Illustrate your answers with neat sketches wherever necessary.

(4) Figures to the right indicate full marks.

(5) Assume suitable data, if necessary.

Marks

1. Attempt any FIVE of the following : 10

(a) Define aspect ratio. Give one example of an aspect ratio.

(b) List any four applications of computer graphics.

(c) Define virtual reality. List any two advantages of virtual reality.

(d) List any two line drawing algorithms. Also, list two merits of any line

drawing algorithm.

(e) Define convex and concave polygons.

(f) What is homogeneous co-ordinate ? Why is it required ?

(g) Write the transformation matrix for y-shear.

[1 of 4] P.T.O.
22318 [2 of 4]
2. Attempt any THREE of the following : 12

(a) Compare Vector scan display and raster scan display. (Write any 4 points.)

(b) Rephrase the Bresenham’s algorithm to plot 1/8th of the circle and write the
algorithm required to plot the same.

(c) Translate the polygon with co-ordinates A(3, 6), B(8, 11) & C(11, 3) by 2
units in X direction and 3 units in Y direction.

(d) Write the midpoint subdivision algorithm for line clipping.

3. Attempt any THREE of the following : 12

(a) State the different character generation methods. Describe any one with
diagram.

(b) Obtain a transformation matrix for rotating an object about a specified pivot
point.

(c) Describe Sutherland-Hodgeman algorithm for polygon clipping.

(d) Given the vertices of Bezier polygon as P0(1, 1), P1(2, 3), P2(4, 3) & P3(3, 1),
determine five points on Bezier curves.

4. Attempt any THREE of the following : 12

(a) Describe the vector scan display technique with neat diagram.

(b) Consider the line from (0, 0) to (4, 6). Use the simple DDA algorithm to
rasterize this line.

(c) Consider a square A(1, 0), B(0, 0), C(0, 1), D(1, 1). Rotate the square by 45
anti-clockwise direction followed by reflection about X-axis.

(d) Use the Cohen-Sutherland outcode algorithm to clip line P1(40, 15) – P2(75, 45)
against a window A(50, 10), B(80, 10), C(80, 40), D(50, 40).

(e) What is interpolation ? Describe the Lagrangian interpolation method.


22318 [3 of 4]
5. Attempt any TWO of the following : 12

(a) Consider the line from (5, 5) to (13, 9). Use the Bresenham’s algorithm to
rasterize the line.

(b) Apply the shearing transformation to square with A(0, 0), B(1, 0), C(1, 1),
D(0, 1) as given below :

(i) Shear Parameter value of 0.5 relative to the line yref = –1.

(ii) Shear Parameter value of 0.5 relative to the line xref = –1

(c) Write a program in ‘C’ to generate Hilbert’s curve.

6. Attempt any TWO of the following : 12

(a) Write a program in ‘C’ for DDA circle drawing algorithm.

(b) Perform a 45 rotation of a triangle A(0, 0), B(1, 1), C(5, 2)

(i) About the origin

(ii) About P(–1, –1)

(c) Apply the Liang-Barsky algorithm to the line with co-ordinates (30, 60) &
(60, 25) against the window :

(Xmin, Ymin) = (10, 10) & (Xmax, Ymax) = (50, 50)

_______________

P.T.O.
22318 [4 of 4]
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

SUMMER – 19 EXAMINATION
Subject Name: Computer Graphics Model Answer Subject Code: 22318
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given
in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner
may try to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components
indicated in the figure. The figures drawn by candidate and model answer may
vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the
assumed constant values may vary and there may be some difference in the
candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner
of relevant answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program
based on equivalent concept.

Q. Sub Answer Marking


No. Q. Scheme
N.
1 Attempt any FIVE of the following 10 M
a Define aspect ratio. Give one example of an aspect ratio 2M
Ans Aspect ratio: It is the ratio of the number of vertical points to the number of Definition-
horizontal points necessary to produce equal length lines in both directions on the 1M
screen. Example-
or 1M
In computer graphics, the relative horizontal and vertical sizes. For example, if a
graphic has an aspect ratio of 2:1, it means that the width is twice as large as the
height.
or
Aspect ratio is the ratio between width of an image and the height of an image.

Example: The term is also used to describe the dimensions of a display resolution.
For example, a resolution of 800x600, 1027x768, 1600x1200 has an aspect ratio
of 4:3.
Resolution 1280x1024 has an aspect ratio 5:4
Resolution 2160x1440, 2560x1700 has an aspect ratio 3:2

b List any four applications of computer graphics. 2M

Page 1 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Ans Listing of
four
applications-
2M

 DTP (Desktop Publishing)


 Graphical User Interface (GUI)
 Computer-Aided Design
 Computer-Aided Learning (Cal)
 Animations
 Computer Art
 Entertainment
 Education and training
 Image processing
 Medical Applications
 Presentation and Business Graphics
 Simulation and Virtual Reality
c Define virtual reality. List any two advantages of virtual reality. 2M
Ans Virtual reality (VR) means experiencing things through our computers that don't Definition-
really exist. 1M
OR Any two
Virtual Reality (VR) is the use of computer technology to create a simulated Advantages-
environment. Instead of viewing a screen in front of them, users are immersed and 1M
able to interact with 3D worlds.

Advantages:
 Virtual reality creates a realistic world
 Through Virtual Reality user can experiment with an artificial
environment.
 Virtual Reality make the education more easily and comfort.
 It enables user to explore places.
 Virtual Reality has made watching more enjoyable than reading.
Virtual reality widely used in video games, engineering, entertainment, education,
design, films, media, medicine and many more.
d List any two line drawing algorithms. Also, list two merits of any line 2M
drawing algorithm.
Ans Line drawing algorithms: Listing-1 M

Page 2 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

 Digital Differential Analyzer (DDA) algorithm Two merits-


 Bresenham’s algorithm 1M

Merits of DDA algorithms:


 It is the simplest algorithm and it does not require special skills for
implementation.
 It is a faster method for calculating pixel positions than the direct use of
equation y = mx + b. It eliminates the multiplication in the equation by
making use of raster characteristics, so that appropriate increments are
applied in the x or v direction to find the pixel positions along the line path
 Floating point Addition is still needed.

Merits of Bresenham’s Algorithm:


 Bresenhams algorithm is faster than DDA algorithm
 Bresenhams algorithm is more efficient and much accurate than DDA
algorithm.
 Bresenham's line algorithm is a highly efficient incremental method over
DDA.
 Bresenhams algorithm can draw circles and curves with much more
accuracy than DDA algorithm.
It produces mathematically accurate results using only integer addition,
subtraction, and multiplication by 2, which can be accomplished by a simple
arithmetic shift operation.
e Define convex and concave polygons. 2M
Ans Convex Polygon: It is a polygon in which if you take any two positions of Each 1 M
polygon then all the points on the line segment joining these two points fall within
the polygon itself.

Concave Polygon: It is a polygon in which if you take any two positions of


polygon then all the points on the line segment joining these two points does not
fall entirely within the polygon.

f What is homogeneous co-ordinate? Why is it required? 2M


Ans Homogeneous coordinates are another way to represent points to simplify the way Definition-1

Page 3 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

in which we express affine transformations. M


Normally, book-keeping would become tedious when affine transformations of the Why

 required-1
form A p + t are composed. With homogeneous coordinates, affine M
transformations become matrices, and composition of transformations is as simple
as matrix multiplication.
 ^ 
With homogeneous coordinates, a point p is augmented with a 1, to form p =  p 
1
.
 
All points (p, ) represent the same point p for real   0.

OR
We have to use 3×3 transformation matrix instead of 2×2 transformation matrix.
To convert a 2×2 matrix to 3×3 matrix, we have to add an extra dummy coordinate
W. In this way, we can represent the point by 3 numbers instead of 2 numbers,
which is called Homogenous Coordinate system.

 Homogeneous coordinates are used extensively in computer vision and


graphics because they allow common operations such as translation,
rotation, scaling and perspective projection to be implemented as matrix
operations
3D graphics hardware can be specialized to perform matrix multiplications on 4x4
matrices.
g Write the transformation matrix for y-shear. 2M
Ans The Y-Shear can be represented in matrix from as: For matrix-2
M

2 Attempt any THREE of the following 12 M


a Compare vector scan display and raster scan display (write any 4 points) 4M
Ans Raster Vector Any four
Raster graphics are composed of Vector graphics are composed point-4 M
pixels. of paths.
Raster graphics are resolution Vector graphics are resolution
dependent. independent
More expensive Less expensive.
Graphics primitives are Scan conversion is not required
specified in terms of their
endpoints and must be scan
converted into their
Page 4 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

corresponding points in the


frame buffer.
It required separate scan Scan conversion hardware is not
conversion hardware. required.
Raster display has ability to Vector display only draws lines
display areas filled with solid and characters
colors or patterns.
It uses interlacing It does not used interlacing
This displays have lower This displays have higher
resolution resolution
They occupies more space They occupies less space
which depends on image
quality.
File extensions are: File extensions are:
.bmp, .gif, .jpg, .tif .pdf, .ai, .svg, .eps, .dxf

b Rephrase the Bresenham’s algorithm to plot 1/8th of the circle and write the 4M
algorithm required to plot the same.
Ans The key feature of circle that it is highly symmetric. So, for whole 360 degree of Rephrase-2
circle we will divide it in 8-parts each octant of 45 degree. In order to that we will M
use Bresenham’s Circle Algorithm for calculation of the locations of the pixels in Algorithm-2
the first octant of 45 degrees. It assumes that the circle is centered on the origin. M
So for every pixel (x, y) it calculates, we draw a pixel in each of the 8 octants of
the circle as shown below:

Algorithm:
Step 1: Read the radius of circle (r).
Step 2: Set decision parameter d = 3 – 2r.
Step 3: x=0 and y=r.
Step 4: do
{
Plot (x,y)
If(d<0) then

Page 5 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

{
d = d + 4x + 6
}
Else
{
d=d + 4(x-y) + 10
y=y-1
}
X=x-1
}
While(x<y)
Step 5: stop
Plotting 8 points, each point in one octant
Call Putpixel (X + h, Y + k).
Call Putpixel (-X + h, Y + k).
Call Putpixel (X + h, -Y + k).
Call Putpixel (-X + h, -Y + k).
Call Putpixel (Y + h, X + k).
Call Putpixel (-Y + h, X + k).
Call Putpixel (Y + h, -X - k).
Call Putpixel (-Y + h,-X + k).
c Translate the polygon with co-ordinates A (3, 6), B (8, 11), & C (11, 3) by 2 4M for
units in X direction and 3 units in Y direction. proper
solution
Ans X’=x+tx
Y’=y+ty
tx=2
ty=3

for point A(3,6)


x’=3+2=5
y’=6+3=9

for point B(8,11)


x’=8+2=10
y’=11+3=14

for point C(11,3)


x’=11+2=13
y’=3+3=6

A’=(x’,y’)=(5,9)

Page 6 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

B’=(x’,y’)=(10,14)
C’=(x’,y’)=(13,6)

d Write the midpoint subdivision algorithm for line clipping. 4M


Ans Step 1: Scan two end points for the line P1(x1, y1) and P2(x2, y2). Algorithm-4
Step 2: Scan corners for the window as (x1, y1) and (x2, y2). M
Step 3:Assign the region codes for endpoints P1 and P2 by initializing code with
0000.
Bit 1 - if (x < x1)
Bit 2 - if (x > x2)
Bit 3 - if (y < y2)
Bit 4 - if (y > y1)
Step 4: Check for visibility of line P1, P2.
 If region codes for both end points are zero then the line is visible, draw it
and jump to step 6.
 If region codes for end points are not zero and the logical Anding operation
of them is also not zero then the line is invisible, reject it and jump to step
6.
 If region codes for end points does not satisfies the condition in 4 (i) and 4
(ii) then line is partly visible.
Step5: Find midpoint of line and divide it into two equal line segments and repeat
steps 3 through 5 for both subdivided line segments until you get completely
visible and completely invisible line segments.
Step 6: Exit.

3 Attempt any THREE of the following 12 M


a State the different character generation methods. Describe any one with 4M
diagram.
Ans Character Generator Methods: Listing-1 M
and any one
1) Stroke Method method-3 M
2) Bitmap Method

Page 7 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

3) Starburst Method

1) STROKE METHOD

 Stroke method is based on natural method of text written by human being. In


this method graph is drawing in the form of line by line.
 Line drawing algorithm DDA follows this method for line drawing.
 This method uses small line segments to generate a character. The small
series of line segments are drawn like a stroke of pen to form a character.
 We can build our own stroke method character generator by calls to the line
drawing algorithm. Here it is necessary to decide which line segments are
needed for each character and then drawing these segments using line
drawing algorithm.

2)BITMAP METHOD

 Bitmap method is a called dot-matrix method as the name suggests this


method use array of bits for generating a character. These dots are the
points for array whose size is fixed.
 In bit matrix method when the dots is stored in the form of array the value 1
in array represent the characters i.e. where the dots appear we represent that
position with numerical value 1 and the value where dots are not present is
represented by 0 in array.
 It is also called dot matrix because in this method characters are represented
by an array of dots in the matrix form. It is a two dimensional array having
columns and rows.
A 5x7 array is commonly used to represent characters. However 7x9 and 9x13
arrays are also used. Higher resolution devices such as inkjet printer or laser
printer may use character arrays that are over 100x100.

Page 8 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

3) Starbust method:

In this method a fix pattern of line segments are used to generate characters. Out
of these 24 line segments, segments required to display for particular character are
highlighted. This method of character generation is called starbust method because
of its characteristic appearance

The starbust patterns for characters A and M. the patterns for particular characters
are stored in the form of 24 bit code, each bit representing one line segment. The
bit is set to one to highlight the line segment; otherwise it is set to zero. For
example, 24-bit code for Character A is 0011 0000 0011 1100 1110 0001 and for
character M is 0000 0011 0000 1100 1111 0011.

This method of character generation has some disadvantages. They are

1. The 24-bits are required to represent a character. Hence more memory is


required.

2. Requires code conversion software to display character from its 24-bit code.

3. Character quality is poor. It is worst for curve shaped characters.

Page 9 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Character A : 0011 0000 0011 1100 1110 0001


Character M:0000 0011 0000 1100 1111 0011

b Obtain a transformation matrix for rotating an object about a specified pivot 4M


point.
Ans To do rotation of an object about any selected arbitrary point P1(x1 ,y1), following Proper
sequence of operations shall be performed. Explanation
4M
1. Translate: Translate an object so that arbitrary point P1 is moved to coordinate
origin.
2. Rotate: Rotate object about origin.
3. Translate: Translate object so that arbitrary point P1 is moved back to the its
original position.
Note: Here to do one operation we are doing the sequence of three operations. So
it is called as composite transformation or concatenation.
Rotate about point P1(x1,y1).
1) Translate P1 to origin.
2) Rotate
3) Translate back to P1.
Equation for this composite transformation matrix form is as follows:

Here (x1,y1) are coordinates of point P1 and hence are translation factors tx and
ty; we want to move P1 to origin , x1 and y1 are x and y distances to P1and hence
it is translation factor.

Page 10 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

It is demonstrated in following figure:

c Describe Sutherland-Hodgeman algorithm for polygon clipping.


Ans  In Sutherland-Hodgeman, a polygon is clipped by processing the polygon Explanation-
boundary as a whole against each window edge. Clipping window must be 1 M and
convex. Algorithm-
 This could be accomplished by processing all polygon vertices against 3M
each clip rectangle boundary in turn beginning with the original 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 then be successively passed to a right boundary
clipper, a top boundary clipper and a bottom boundary clipper.
 At each step a new set of polygon vertices us generated and passed to the next
window boundary clipper. This is the logic used in Sutherland-Hodgeman
algorithm.

Fig. Clipping polygon against successive window boundaries


 The output of algorithm is a list of polygon vertices all of which are on the
visible side of clipping plane. Such each edge of the polygon is individually
compared with the clipping plane.
 This is achieved by processing two vertices of each edge of the polygon
Page 11 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

around the clipping boundary or plane.


 This results in four possible relationships between the edge and clipping plane.
1. If first vertex of polygon edge is outside and second is inside window
boundary, then intersection point of polygon edge with window boundary
and second vertex are added to output vertices set as shown in Fig. 6.13.

2. If both vertices of edge are inside window boundary, then add only second
vertex to output set as shown in Fig. 6.14.

3. If first vertex of edge is inside and second is outside of window boundary


then point of intersection of edge with window boundary is stored in
output set as shown in Fig. 6.15.

4. If both vertices of edges are outside of window boundary then those


vertices are rejected as shown in Fig. 6.16.

 Going through above four cases we can realize that there are two key
processes in this algorithm:
1. Determine the visibility of point or vertex (Inside – Outside Test)
2. Determine the intersection of the polygon edge and clipping plane.
 The second key process in Sutherland-Hodgeman polygon clipping algorithm
is to determine the intersection of the polygon edge and clipping plane.
Page 12 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

 Assume that we're clipping a polygon’s edge with vertices at (x1, y1) and (x2,
y2) against a clip window with vertices at (xmin, ymin) and (xmax, ymax).
1. The location (IX, IY) of the intersection of the edge with the left side of the
window is:
(i) IX = xmin
(ii) IY = slope*(xmin – x1) + y1, where the slope = (y2 – y1)/(x2 – x1).
2. The location of the intersection of the edge with the right side of the
window is:
(i) IX = xmax
(ii) IY = slope*(xmax – x1) + y1, where the slope = (y2 – y1)/(x2 – x1)
3. The intersection of the polygon's edge with the top side of the window is:
(i) IX = x1 + (ymax – y1) / slope
(ii) IY = ymax
4. Finally, the intersection of the edge with the bottom side of the window is:
(i) IX = x1 + (ymin – y1) / slope
(ii) IY = ymin
Algorithm for Sutherland-Hodgeman Polygon Clipping:
Step 1: Read co-ordinates of all vertices of the polygon.
Step 2: Read co-ordinates of the clipping window.
Step 3: Consider the left edge of window.
Step 4: Compare vertices of each of polygon, individually with the clipping plane.
Step 5: Save the resulting intersections and vertices in the new list of vertices
according to four possible relationships between the edge and the
clipping boundary.
Step 6: Repeat the steps 4 and 5 for remaining edges of clipping window. Each
time resultant list of vertices is successively passed to process next
edge of clipping window.
Step 7: Stop.

d Given the vertices of Bezier Polygon as P0(1, 1), P1(2,3), P2(4,3), P3(3,1), 4M
determine five points on Bezier Curve.

Page 13 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Ans Proper result


4M

Page 14 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Page 15 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

4 Attempt any THREE of the following 12 M


a Describe the vector scan display techniques with neat diagram. 4M
Ans  A pen plotter operates in a similar way and is an example of a random- Explanation
scan, hard-copy device. 3M
 When operated as a random-scan display unit, a CRT has the electron Diagram 1
beam directed only to the parts of the screen where a picture is to be M
drawn.
 Random scan monitors draw a picture one line at a time and for this reason
are also referred to as vector displays (or stroke-writing or calligraphic
displays).

 Here the electron gun of a CRT illuminate’s points and / or straight lines in
any order. If we want a line connecting point A with point B on vector
graphics display, we simply drive the beam reflection circuitry, which will
cause beam to go directly from point A to point B.
 Refresh rate on a random-scan system depends on the number of lines to
be displayed.
 Picture definition stored as a set of line drawing commands in an area of
memory called “refresh display file” or also called as display list or
display program or refresh buffer.
 To display a given picture, the system cycles through the set of commands
in the display file, drawing each component line by line in turn. After all
line drawing commands have been processed, the system cycles back to
the first line drawing command in the list. And repeats the procedure of
scan, display and retrace.
 This displays to draw all the component lines of picture 30 to 60
frames/second
 Random scan system is designed for line drawing applications; hence
cannot display realistic shaded scenes.
 Vector displays produces smooth line drawings but raster produces jagged
lines that are plotted points
 Random scan suitable for applications like engineering and scientific
drawings
 Graphics patterns are displayed by directing the electron beam along the
component lines of the picture
 A scene is then drawn one line at a time by positioning the beam to fill in
the line between specified end points.

Page 16 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

b Consider the line from (0,0) to (4,6). Use the simple DDA algorithm to 4M
rasterize this line.
Ans Evaluating steps 1 to 5 in the DDA algorithm we have, Proper result
4M
Xl = 0, Y1 = 0
X2 = 4, Y2 = 6
Length = |Y2 – Y1| = 6
∆X=|X2 – X1| / Length = 4/6
∆Y =|Y2 – Yl| / Length = 6/6 = 1
Initial value for,

X=0 + 0.5  (4/6) = 0.5

Y =0 + 0.5  (1) = 0.5


Plot integer now:
1. Plot (0,0), x=x+∆X=0.5+4/6=1.167, y=y+ ∆Y=0.5+1=1.5
2.Plot (1,1), x=x+∆X=1.167+4/6=1.833 y=y+ ∆Y=1.5+1=2.5
3.Plot (1,2), x=x+∆X=1.833+4/6=2.5 y=y+ ∆Y=2.5+1=3.5
4.Plot (2,3), x=x+∆X=2.5+4/6=3.167 y=y+ ∆Y=3.5+1=4.5
5.Plot (3,4), x=x+∆X=3.167+4/6=3.833 y=y+ ∆Y=4.5+1=5.5
6.Plot (3,5), x=x+∆X=3.833+4/6=4.5 y=y+ ∆Y=5.5+1=6.5

Tabulating the results of each iteration in the step 7 we get,

i Plot x y
0.5 0.5
1 (0,0) 1.167 1.5
2 (1,1) 1.833 2.5
3 (1,2) 2.5 3.5
4 (2,3) 3.167 4.5
5 (3,4) 3.833 5.5
6 (3,5) 4.5 6.5

Page 17 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Fig. 2.2

 The results are plotted as shown in the Fig. 2.2. It shows that the rasterized line
lies to both sides of the actual line, i.e. the algorithm is orientation dependent.

c Consider a square A(1,0), B(0,0), C(0,1), D(1,1). Rotate the square by 450 4M
anti-clockwise direction followed by reflection about X-axis.
Ans Rotation +
Reflection
Matrix 1 M
final
Result= 3 M

Page 18 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

d Use Cohen-Sutherland outcode algorithm to clip line PI (40, 15) -- P2 (75. 4M


45) against a window A (50, 10), B (80, 10). C(80, 40) & D(50,40).

Ans P1 (40, 15) - P2 (75, 45) Wxi = 50 Wy2 = 40 Wx2 = 80 Wy2 = 10 Proper
result 4 M
Point Endcode ANDing
P1 0001 0000 (Partially visible)
P2 0000

6 45−15
y1 = m(xL – x ) + y = 7(50-40)+15 m = 75−40

Page 19 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

= 23.57
1 7
x1 = 𝑚 (yT – y ) + x = 6(40-50)+40 = 69.16
6
y2 = m(xR – x ) + y = 7(80-40)+15 = 49.28
1 7
x2 = 𝑚 (yB – y ) + x = 6(10-15)+40 = 34.16

Hence:

e What is interpolation? Describe the Lagrangian Interpolation method. 4M


Ans Specify a spline curve by giving a set of coordinate positions, called control Definition-
points, which indicates the general shape of the curve These, control points 1M
are then fitted with piecewise continuous parametric polynomial functions in Description
one of two ways. When polynomial sections are fitted so that the curve passes of
through each control point, the resulting curve is said to interpolate the set of Lagrangian
control points. On the other hand, when the polynomials are fitted to the method- 3
general control-point path without necessarily passing through any control M
point, the resulting curve is said to approximate the set of control points
interpolation curves are commonly used to digitize drawings or to specify
animation paths. Approximation curves are primarily used as design tools to
structure object surfaces an approximation spline surface credited for a
design application. Straight lines connect the control-point positions above the
surface

Page 20 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Lagrangian Interpolation Method:

5 Attempt any TWO of the following : 12 M


a Consider the line from (5,5) to (13,9). Use the Bresenham’s algorithm to 6M
rasterize the line.
Ans Bresenham Line Drawing Calculator By putting x1,x2 and y1,y2 Value it Show Remark:
The Result In Step By Step order, and Result Brief Calculation Which Is Preliminary
Calculated by Bresenham Line Drawing Algorithm. Bresenham Line Drawing Calculations
Algorithm display result in tables. Starting Points is x1,y1 and Ending points is 2 M; Step
x2,y2. wise plot 4
Preliminary Calculations: M

x1 = 5 | y1 = 5 | & | x2 = 13 | y2 = 9

Calculation Result

Page 21 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

dx = abs(x1 - 8 = abs(5 - 13)


x2)
dy = abs(y1 - 4 = abs(5 - 9)
y2)
p = 2 * (dy - dx) -8 = 2 * (4 - 8)
ELSE x = x1 | y = y1 | end =
x2
x = 5 | y = 5 | end = 13
Stepwise Plot:
STEP while(x x if(p < OUTPUT
< end) = 0) { p
x =p+
+ 2*
1 dy }
else{
p=p
+2*
(dy -
dx) }
1 6 < 13 6 IF 0 x=6|y=
= = -8 5
5 +2*
+ 4
1
2 7 < 13 7 ELSE x=7|y=
= -8 = 6
6 0+2
+ * (4 -
1 8)
3 8 < 13 8 IF 0 x=8|y=
= = -8 6
7 +2*
+ 4
1
4 9 < 13 9 ELSE x=9|y=
= -8 = 7
8 0+2
+ * (4 -

Page 22 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

1 8)
5 10 < 13 10 IF 0 x = 10 | y
= = -8 =7
9 +2*
+ 4
1
6 11 < 13 11 ELSE x = 11 | y
= -8 = =8
10 0+2
+ * (4 -
1 8)
7 12 < 13 12 IF 0 x = 12 | y
= = -8 =8
11 +2*
+ 4
1
8 13 < 13 13 ELSE x = 13 | y
= -8 = =9
12 0+2
+ * (4 -
1 8)
b Apply the shearing transformation to square with A(0,0), B(1,0), C(1,1), 6M
D(0,1) as given below.
(i) Shear Parameter value of 0.5 relative to the line yref = -1.
(ii) Shear Parameter value of 0.5 relative to the line xref = -1.

Ans We can represent the given square ABCD, in matrix form, using homogeneous Each sub
coordinates of vertices as: problem – 3
𝐴 0 0 1 M
𝐵 1 0 1
[ ]
𝐶 1 1 1
𝐷 0 1 1
i) Here Shx = 0.5 and yref = -1
𝐴` 𝐴 1 0 0
𝐵`
[ ] = [ ]∗[ 𝐵 𝑆ℎ𝑥 1 0]
𝐶` 𝐶
−𝑆ℎ𝑥 ∗ 𝑦𝑟𝑒𝑓 0 1
𝐷` 𝐷

0 0 1 1 0 0
1 0 1
= [ ] ∗ [0.5 1 0]
1 1 1
0 1 1 0.5 0 1

Page 23 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

0.5 0 1
1.5 0 1
= [ ]
2 1 1
1 1 1
Shearing Transformation Result:-

ii) Here Shy = 0.5 and xref = -1


𝐴` 𝐴 1 𝑆ℎ𝑦 0
[𝐵`] = 𝐵
[ ] ∗ [0 1 0]
𝐶` 𝐶
0 −𝑆ℎ𝑦 ∗ 𝑥𝑟𝑒𝑓 1
𝐷` 𝐷

0 0 1 1 0.5 0
1 0 1
= [ ] ∗ [0 1 0]
1 1 1
0 1 1 0 0.5 1

0 0.5 1
1 1 1
= [ ]
1 2 1
0 1.5 1
Shearing Transformation Result:-

c Write a program in ‘C’ to generate Hilbert’s curve. 6M


Ans Correct logic – 6 Marks)
Page 24 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <math.h>

void move(int j,int h,int &x,int &y)


{
if(j==1)
y-=h;
else if(j==2)
x+=h;
else if(j==3)
y+=h;
else if(j==4)
x-=h;
lineto(x,y);
}

void hilbert(int r,int d,int l,int u,int i,int h,int &x,int &y)
{
if(i>0)
{
i--;
hilbert(d,r,u,l,i,h,x,y);
move(r,h,x,y);
hilbert(r,d,l,u,i,h,x,y);
move(d,h,x,y);
hilbert(r,d,l,u,i,h,x,y);
move(l,h,x,y);
hilbert(u,l,d,r,i,h,x,y);
}
}

int main()
{
int n,x1,y1;
int x0=50,y0=150,x,y,h=10,r=2,d=3,l=4,u=1;

printf)"\nGive the value of n: ");


scanf(“%d”,&n);
x=x0;y=y0;
int gm,gd=DETECT;
initgraph(&gd,&gm,NULL);
moveto(x,y);
hilbert(r,d,l,u,n,h,x,y);

Page 25 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

delay(10000);
closegraph();
return 0;
}

6 Attempt any TWO of the following 12 M


a Write a Program in ‘C’ for DDA Circle drawing algorithm 6M
Ans #include<stdio.h> Correct
#include<conio.h> Program 6
#include<graphics.h> marks
#include<math.h>
void main()
{
int gdriver=DETECT,gmode,errorcode,tmp,i=1,rds;
float st_x,st_y,x1,x2,y1,y2,ep;
initgraph(&gdriver,&gmode,"C:\\TC\\BGI");
printf("Enter Radius:");
scanf("%d",&rds);
while(rds>pow(2,i))
i++;
ep=1/pow(2,i);
x1=rds; y1=0;
st_x=rds; st_y=0;
do
{ x2=x1+(y1*ep);
y2=y1-(x2*ep);
putpixel(x2+200,y2+200,10);
x1=x2;
y1=y2;
}while((y1-st_y)<ep || (st_x-x1)>ep);
getch();
}
b Perform a 45o rotation of triangle A(0,0), B(1,1), C(5,2) 6M
(i) About the origin (ii) About P(-1,-1)

Ans About the Origin: - Each Sub


problem – 3
M

Page 26 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

c Apply the Liang-Barsky algorithm to the line with co-ordinate (30,60) & 6M
(60,25) against the window:
(Xmin, Ymin) = (10.10) & (Xmax,Ymax) = (50,50)

Page 27 | 2 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Ans Given: Remark:


Calculation
(Xmin,Ymin)=(10,10) and (Xmax,Ymax)=(50,50)
of each side
P1 (30, 60) and P2 = (60, 25)
1 M;
Solution: Decision of
displaying
Set Umin = 0 and Umax = 1 line
ULeft= q1 / p1 coordinates
= X1 – Xmin / - Δ X with
justification
= 30 – 10 / - (60 - 30) 2M
= 20 / - 30
= -0.67
URight= q2 / p2
= Xmax – X1/ ΔX
= 50 – 30 / (60 - 30)
= 20 / 30
= 0.67
UBottom= q3 / p3
= Y1 – Ymin / - ΔY
= 60 – 10 / - (25 – 60)
= 50 / 35
= 1.43
UTop= q4 / p4
= Ymax – Y1 / ΔY
= 50 – 60 / (25 - 60)
= -10 / - 35
= 0.29
Since ULeft=−0.57which is less than Umin. Therefore we ignore it.
Similarly UBottom=1.43 which is greater than Umax. So we ignore it.
URight=Umin = 0.67 (Entering)
UTop=Umax = 0.29 (Exiting)
We have UTop= 0.29 and URight= 0.67
Q – P = (ΔX, ΔY) = (30, -35)
Since Umin>Umax, there is no line segment to draw.

Page 28 | 2 8

You might also like