Sie sind auf Seite 1von 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Q.1
a.
Ans:

Subject Code: 12112

Attempt any Six of the Following


(6 x 2 = 12)
What is polygon? What are types of Polygon?
*(1 mark for definition; 1 mark for types list)
Definition: - A closed plane figure is having three or more sides is called as polygon.
Triangles, rectangles, and octagons are all examples of polygons. A regular polygon is a
polygon all of whose sides are the same lengths and all of whose interior angles are the
same measures.
Types of Polygon
The polygons are divided into two categories as,
1) Convex Polygon.
2) Concave Polygon.
1) Convex Polygon:A convex polygon is a polygon in which the line segment joining any two points the
polygon lies completely inside the polygon. So it is very easy to perform inside test on a
pixel to be filled with given color.

Fig (a) Convex Polygon


2) Concave Polygon: A concave polygon is a polygon in which the line segment joining any two points within
the polygon may or may not lay completely inside the polygon.

Fig (b) Conclave Polygon


b

Give general criteria applied for line drawing algorithm.


*(All four criteria are expected mark for each criteria)
Ans: General criteria of any line drawing algorithm are as follow.
1.
Line must appear straight.
2.
Line must start and end properly.
3.
Line should be drawn at rapid pace.
4.
Line must have constant intensity to their length.
c. Define the terms windowing and clipping
*(1 mark for windowing and 1 mark for clipping)
Ans: i Windowing: -A rectangular area specified in world co-ordinates is defined as window. The
window defines what is to be viewed. The window is generally rectangle in size.
ii. Clipping:- The method which determines the portions of a picture that is either inside or
outside of a specified region of space is known as clipping. The region against which an
object is to be clipped is called a clip window or clipping window. Normally clipping window
Computer Engineering Group

Page 1 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

is in a rectangular shape. This algorithm identifies which points, lines or portions of lines
lies within the clipping window. These points, lines or portions of lines are displayed and
remaining points, portion is discarded. This visible and invisible portions of picture is
depend on whether elements are inside or outside to given region.
d. List any four properties of Bezier curve
*(Any 4 properties are expected mark for one property)
Ans: Properties of Bezier Curve
1. It always passes through first and last control point.
2. Tangent vectors at ends of the curve have same direction as first and last polygon
spans respectively.
3. It follows the shape of defining polygon.
4. It is contained within the convex hull of defining polygon.
5. Degree of polynomial defining the curve segments is equal to the total number of
control points minus 1.
6. Order of polynomial defining the curve segments is equal to the total number of control
points
7. Basic functions of Bezier curve are real.
e. List some graphics standards
*(four standards are expected mark for one standard)
Ans: 1. CORE
2. Programmers Hierarchical Interactive Graphical Standard (PHIGS)
3. Initial Graphics Exchange Standard (IGES)
4. Computer Graphics Metafile Standard (CGM)
5. Virtual Device Metafile (VDM)
6 Virtual Device Interface (VDI)
f.

Draw labeled diagram of shadow mask CRT.


*(1 mark for diagram, 1 mark for labeling)

Ans:

Fig Shadow Mask CRT.

Computer Engineering Group

Page 2 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

g. Describe any one graphics mode graphics function with syntax.


*(Any 1 function is expected; 1 mark for explanation, 1 mark for syntax)
Ans: Initgraph( ) : - It is used to initialize graphic mode.
Syntax:- initgraph(int driver, int mode, char path);
Driver:- this argument gives the graphics driver to be used and it interfaces with display
adapter. Some of available graphics drivers are CGA, EGA, VGA etc.
Closegraph( ):- It is used to close graphics mode, when one exit from graphics mode one
shall restore the system to the previous display mode, closegraph function restores the
previous display mode.
Syntax:Closegraph( );
h.

State two merits and demerits of DDA line drawing algorithm


*(1 mark for merit and 1 mark for Demerit)

Ans:
Merits of DDA:It is simple algorithm
It is faster
Demerits of DDA: Floating point arithmetic in DDA algorithm is time consuming
Accumulation of round-off error in successive additions of floating point increment
can cause the calculated point to drift away from the actual line path.
B)
a.
Ans:

Attempt any two of the following


( 2 x 4 = 8)
Explain 2D-transformation matrix for rotation about arbitrary point.
*(2 mark for explanation; 1 mark for diagram; 1 mark for matrix)
Arbitrary point.
An arbitrary point or pivot point is one which is any point other than the origin. Since
rotation of an object is done with respect to origin only hence to perform rotation about
arbitrary point it shall be performed by shifting an object to the origin and then perform
rotation after that the object is again shifted back to its original position.
To perform rotation of an object about any pivot point P following set of operation is done
with given sequence.
Translate: In this operation an object is translated to origin from arbitrary point i.e. the base
of an object is shifted to origin.
Rotate: in this operation, rotate an object at give given angle.
Translate: In this operation an object is translated back to arbitrary point from origin i.e. the
base of an object is shifted to arbitrary point.

Computer Engineering Group

Page 3 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

Fig (a) Before Rotating of Object

Fig (c) after rotating


an object to origin.

Fig (b) After Translation of


an object to origin.

Fig (d) Translation of an object


to original point

Fig gives an idea about rotation operation about arbitrary point in graphics. Fig (a) shows
object at its original position. When rotation starts, the object has to be translated at origin
as shown in fig (b). After that the object is rotated at given angle which is shown in fig (c). In
last step the object is again moved back to its original position by performing translation
given in fig (d).

[ T1.R.T2] =

cos

sin

-sin

cos

-Xp -Yp 1

Xp

Yp

1
0
Xp

0
1
Yp

cos
-sin
-Xp cos + Yp sin

sin
cos
-Xp sin - Yp Cos

cos
-sin
-Xp cos + Yp sin + Xp

0
0
1

sin
cos
-Xp sin - Yp Cos + Yp1

0
0
1

0
0
1

This is how rotation about arbitrary point can be performed.

Computer Engineering Group

Page 4 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

b.
Ans:

Subject Code: 12112

Explain 3D translation and scaling transformation matrix


*(2 marks for 3D translation and 2 marks for Scaling)
Translation: In Euclidean geometry, a translation refers to moving every point at a constant distance
in a specified direction. It is one of the rigid motions. A translation can also be interpreted
as an addition of a constant vector to every point or shifting the origin of the coordinate
system. If v is a fixed vector, then the translation Tv will work as
Tv (P) = P + v
Translation is an affine transformation but not a linear transformation. Homogeneous
coordinates are normally used to represent the translation operator by a matrix. Thus we
write a 3D vector w= (W x W y W z) using four homogeneous coordinates co-ordinates as
w= (W x W y W z 1)
To translate an object by a vector v = [Tx Ty Tz], each homogeneous vector P = [x y z 1]
would need to be multiplied by this translation matrix.

[ T]

[ T * P]

= [X Y Z 1] *

1
0 0
0
1 0
0
0 1
Tx Ty Tz

0
0
0
1

1
0 0
0
1 0
0
0 1
Tx Ty Tz

0
0
0
1

= [x + Tx y + Ty z + Tz
= P + v.

1]

For Example:-

Fig (a) Before Translation

Computer Engineering Group

Fig (b) After Translation

Page 5 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

Scaling Transformation:A scaling can be represented by a scaling matrix. To scale an object by a vector V=
[Sx, Sy, Sz], each point P = [x y z] would need to be multiplied with this scaling matrix.

Sv

P * Sv = [ X Y Z] *

Sx 0 0
0 Sy 0
0 0 Sz

Sx 0 0
0 Sy 0
0 0 Sz

= [SxX SyY SzZ ]

Such a scaling changes the diameter of an object by a factor between te scale factors, the
area by a factor between the smallest and the largest product of two scale factors, and the
volume by the product of all three.
In homogeneous coordinates, since translation cannot be accomplished with a 3 X 3
matrix. To scale an object by a vector V= [Sx Sy Sz ] each homogeneous vector P = [X Y
Z 1] would need to be multiplied with the scaling matrix.

Sx 0
Sv

0
0

0
Sx
P * Sv = [ X Y Z 1] *

Sy 0 0
0 Sz 0

0
0

Fig (a) Before Scaling


Computer Engineering Group

0 0
Sy 0 0
0 Sz 0

[S X
x

SyY SzZ 1

Fig (b) After Scaling


Page 6 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

c. Write a C code for scaling a line


*(A demo code is given any relevant code shall be consider and assessed)
Ans:

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm=DETECT,sx,sy;
clrscr();
printf("\nEnter Scaling factors (SX and SY)");
scanf("%d%d",&sx,&sy);
initgraph(&gd,&gm,"D:\\TC\\BGI");
line(100,100,200,200);
getch();
line(100,100,200*sx,200*sy);
getch();
}

Q.2. Attempt any four of the following


( 4 x 4 = 16)
a. Write a C-program to draw a circle filled with blue color.
*(A demo code is given any relevant code shall be consider and assessed)
Ans: #include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm=DETECT,sx,sy;
clrscr();
initgraph(&gd,&gm,"D:\\TC\\BGI");
circle(320,240,100);
floodfill(320,240,1);
getch();
}
b. Describe working of Direct View Storage tube
(3 marks for explanation of DVST 1 mark for diagram)
Ans: In Raster display and all refresh display one may need to refresh the screen to maintain
consistent image on screen else flickering occurs. An alternative solution to these display
devices with inherent image storage capability, which stores image in display device for
displaying. DVST uses a storage grid which stores picture information as a charge
distribution just behind phosphor coated screen.
It consists of two electron guns as writing gun and flood gun. Writing gun stores picture
pattern as a positive charge on storage grid. This picture pattern is transferred to phosphor
by continuous flood of electron generated from flood electrons. Electrons pass through
Computer Engineering Group

Page 7 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

collector at low speed and are attracted by positively charged picture pattern on storage
grid and are repelled by rest. The attracted electrons by positive picture pattern pass right
through it and strike on phosphor making it visible on screen.

c.

Explain any two graphics file formats


*(Any two graphics file formats are expected 2 marks for each)

Ans:
BMP
Bitmap. This was probably the first type of digital image format that I can remember.
Every picture on a computer seemed to be a BMP. In Windows XP the Paint program
saves its images automatically in BMP, however now in Windows Vista images are saved
to JPEG. BMP is the basis platform for many other file types.
JPG, JPEG
(Joint Photographic Experts Group) Jpeg format is used for color photographs, or
any pictures with many blends or gradients. It is not good with sharp edges and tends to
blur them a bit. This format became popular with the invention of the digital camera. Most, if
not all, digital cameras download photos to your computer as a Jpeg file. Obviously the
digital camera manufacturers see the value in high quality images that ultimately take up
less space.
GIF
(Graphics Interchange Format) Gif format is best used for text, line drawings,
screen shots, cartoons, and animations. Gif is limited to a total number of 256 colors or
less. It is commonly used for fast loading web pages. It also makes a great banner or logo
for your webpage. Animated pictures are also saved in GIF format. For example, a flashing
banner would be saved as a Gif file.
PNG
(Portable Networks Graphic) Apparently this is one of the best image formats;
however it was not always compatible with all web browsers or image software. Now days it
is the best image format to use for website. I use .png for logos and screen shots.

Computer Engineering Group

Page 8 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

TIFF
(Tagged Image File Format) This file format has not been updated since 1992 and
is now owned by Adobe. It can store an image and data (tag) in the one file. TIFF also
stores files with virtually no compression and therefore is good for storing images that need
to be edited and re-saved without suffering a compression loss. This file is commonly used
for scanning, faxing, word processing, and so on. It is no longer a common file format to
use with your digital photos as a jpeg is great quality and takes up less space.
d. Explain the syntax and use of following methods:
*(2 marks for ellipse and 2 marks for rectangle)
Ans:
i. ellipse( )
ellipse draws an elliptical arc fillellipse draws and fills an ellipse sector draws and fills an
elliptical pie slice
Declaration Syntax:
void far ellipse(int x, int y, int stangle, int endangle,
int xradius, int yradius);
void far fillellipse(int x, int y,
int xradius, int yradius);
void far sector(int x, int y, int stangle, int endangle,
int xradius, int yradius);
Remarks:
ellipse draws an elliptical arc in the current drawing color. fillellipse draws an ellipse, then
fills the ellipse with the current fill color and fill pattern. sector draws and fills an elliptical pie
slice in the current drawing color, then fills it using the pattern and color defined by
setfillstyle or setfillpattern.
Argument
(x,y) Center of ellipse xradius Horizontal axis yradius Vertical axis stangle Starting
angle endangle Ending angle
The ellipse or sector travels from stangle to endangle.
If stangle = 0 and endangle = 360, the call to ellipse draws a complete ellipse.The linestyle
parameter does not affect arcs, circles, ellipses, or pie slices. Only the thickness parameter
is used.

Computer Engineering Group

Page 9 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

ii.

Subject Code: 12112

rectangle( )
rectangle Draws a rectangle (graphics mode)
Declaration Syntax:
void far rectangle(int left, int top, int right, int bottom);
Remarks:
rectangle draws a rectangle in the current line style, thickness, and drawing color.
(left,top) is the upper left corner of the rectangle, and (right,bottom) is its lower right
corner.

e.
Ans:

Draw and explain rotating memory frame buffer used for raster display
*(2 marks for diagram and 2 marks for explanation)
Frame buffer is a large part of computer memory used to store display image. Different kind
of memory can be used for frame buffers like drums, disk or IC shift registers.
To generate a pixel of desired intensity to read the disk or drum. The information stored in
disk or drum is in digital for, hence it is necessary to convert it into analog from using DAC
and then this analog signal is used to generate the pixel.
If only one bit is used to generate the pixel then only black and white picture is possible.
The fig show three tracks used in parallel to provide a frame buffer with eight different
intensity of pixel. Here it is necessary to read the disk or drum again and again to refresh
the display. Therefore the rotating speed of drum is made to coincide with the refresh rate
of the screen. Latency problem puts a limitation on these frame buffers as they require
more time.
Digital
Information
DISK
OR
Drum

D
A
C

3 Bit
DAC

Computer Engineering Group

Electronic gun

Analog
Signal

Screen

Page 10 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

f.

Subject Code: 12112

Given a window whose lower left corner is at (-3 , 1) and upper right corner is at (2,
6). Find the region code for following end points.
(Two marks for each region)

Ans:
From given data for window
Xmin = -3
Ymin = 1
Xmax = 2
Ymax = 6
Bit 1 = 1 if y > Ymax
Bit 2 = 1 if y < Ymin
Bit 3 = 1 if x > Xmax
Bit 4 = 1 if x < Xmin
i.
A( 4 , 2) B( 1 , 7)
For line segment having end points as ( 4, 2)
Substituting values in above four conditions we get,
Code for A = 0001
For line segment having end points as ( 4, 2)
Substituting values in above four conditions we get,
Code for B = 1000
ii.

A( 5 , 7) B( 2 , 10)
For line segment having end points as ( 5, 7)
Substituting values in above four conditions we get,
Code for A = 1001
For line segment having end points as ( 2, 10)
Substituting values in above four conditions we get,
Code for B = 1000

Computer Engineering Group

Page 11 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Q.3.

Attempt any FOUR of the following.

Subject Code: 12112

(4 x 4 = 16)

a) Write C-code for DDA circle drawing algorithm.


(Relevant code 4Marks)
Ans: #include <stdio.h>
#include <conio.h>
#include <math.h>
#include <graphics.h>
Void main ()
{
float x1, y1, x2, y2, x_start, y_start, epsilon;
int gd, gm, i, val;
int rad;
clrscr ();
printf (\t\t CIRCLE DRAWN BY DDA ALGORITHM \n);
printf (\n ENTER THE RADIOUS OF CIRCLE: \n);
scanf (%d, &rad);
detectgraph (&gd, &gm);
initgraph (&gd, &gm, D:\TC3);
x1 = rad*cos (0);
y1 = rad*sin (0);
x_start=x1;
y_start=y1;
i=0;
do
{
val=pow(2, i-1);
i++;
} while (val<rad);
epsilon=1/pow (2,i-1);
do
{
x2=x1+y1*epsilon;
y2=y1-epsilon*x2;
putpixel (200+x2, 200+y2,10);
x1=x2;
y1=y2;
} while ((y1-y_start) <epsilon II (x1-x_start) >epsilon);
getch ();
}

Computer Engineering Group

Page 12 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

b) Explain floodfill algorithm.


(Complete algorithm 4Marks)
Ans: Flood fill algorithms starts from any speed point inside polygon & set it to fill colour.
In Flood Fill method user starts from any point inside polygon & fills the colour to the
neighbouring pixel till polygon boundary is reached. This method has one limitation that is
the polygon has any point of different colour then this method stops colouring the
neighbouring pixel.
Flood fill algorithm
Step 1: Read any seed pixel position (x, y)
Step 2: Check to see if this pixel (x, y) has old interior colour. If old colour, then set it to
new fillcolor.
Step 3: Repeat step 2 for neighbouring pixels of (x, y)
Step 4: If pixel (x, y) does not has old interior colour then stop. (Getpixel, Putpixel and
Flood fill statement can be used to increment the neighbouring pixel).
c) Describe inside/outside test used in polygon filling with example.
(Diagram 2 Marks, Explanation 2 Marks)
Ans: Once the polygon is entered in the display file, we can draw the outline of the polygon. To
show polygon as a solid object we have to set pixel inside the polygon as well as pixels on
the boundary of it. To determine whether or not a point is inside of a polygon, the
inside/outside test is performed.
Simple method of doing this is to construct a line segment between the point in question
and point known to be outside the polygon, as shown in fig. Now count how many
intersections of the line segments with the polygon boundary occur. If there are an odd
number of intersections, then the point in question is inside; otherwise it is outside. This
method is called the even-odd method (inside/outside test) of determining polygon
inside points.

The inside/outside test fails, if the intersection point is vertex of the polygon. Then we
have to look at the other endpoints of the two segments which meet at this vertex. If
these points lie on the same side of the constructed line, then the point in question counts
as an even number of intersections. If they lie on opposite sides of the constructed line,
then the point is counted as a single intersection.

Computer Engineering Group

Page 13 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

d) Write Bresenham line drawing algorithm.


(Relevant algorithm 4Marks)
Ans:

P next = P0 + 2dy 2dx

Computer Engineering Group

Page 14 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

e) Write midpoint circle algorithm.


(Relevant algorithm 4Marks)
Ans: Step1: Read the radius r of the circle
Step2: x=0, y=r
Step3: Calculate initial decision parameter P=1-r
Step4: do
{
putpixel (x, y)
If (P<0)
{
x=x+1
y=y
P= P+2x+1
}
Else
{
x=x+1
y=y-1
P=P+2(x-y) +1
}
} while(x<y)
Step5: Determine symmetrical points in other octants also.
Step 6: STOP
f) What is difference between VGA and SVGA?
(Any 4 valid differences-1 Mark each)
Ans:
VGA
1. Video graphics array used for Analog
signals
2. Introduced by IBM in 1987
3. It has limited colours (256)

SVGA
1. Super Video graphics array used for
Analog signals
2. Introduced by IBM (in 1989) to provide
inter operability and different standards
3. It provides various colour range 16
million colours.

4. It has resolution 640 x 480.

4. It supports resolution 800 x 600 and


1024 x 768

5. It is compatible with graphics and text

5. It has better image quality

Computer Engineering Group

Page 15 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Q.4.

Attempt any TWO of the following.

Subject Code: 12112

(2 x 8 =16)

a) Write C-code for DDA line drawing algorithm.


(Relevant code 8Marks)
Ans:

Computer Engineering Group

Page 16 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

b) Explain midpoint subdivision line clipping algorithm.


(Diagram 4 Marks, Explanation 2 Marks, Algorithm 2Marks)
Ans: Midpoint subdivision line clipping algorithm is as below:
Step1: Accept two end points of line say P1 (x1, y1) and P2 (x2, y2)
Step2: Read lower left and upper right co-ordinates of clipping window.
Step3: Assign 4-bit region code for points P1 and P2.
Step4: Check the category of this line for its visibility.
If line is completely visible draw it and stop.
If line is completely out of clipping window then discard it.
If the line is partially visible then continue the next step.
Step5: Find midpoint of line and divide it into two equal line segments.
Step6: For both divided line segments check the region code for visibility.
Repeat step 5 for partially visible line. And then repeat step 4, 5, and 6 till complete
line is divided into totally visible and invisible line segment.
The process is explained by following figures.

Computer Engineering Group

Page 17 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

c) Explain Hiberts curve and Koch curve with example


(Hiberts curve - Explanation 2 Marks & Diagram 2 Marks, Koch curve - Explanation 2
Marks & Diagram 2 Marks)
Ans: Hiberts curve:
The Hiberts curve is built by successive approximation technique.
If square is divided into four quadrants, we can draw the first approximation of Hiberts
curve by connecting the centre point of each quadrant.

For 2nd approximation Hiberts curve can be drawn by further subdividing each of the
quadrants and connecting their centres before moving to the next major quadrant.
Such more further approximations level can be increased to achieve the accuracy of the
Hiberts curve.
The special property of Hiberts curves it that it is infinite in length when further
approximations are mode. As well it passes through each quadrant but it never crosses
the existing lines.
It is used in polygon filling object or to draw mountain shape object.
Koch curve:
The Koch curve can be drawn by dividing a line into four equal segments with scaling
factor 1/3 and middle two segments are so adjusted that they form adjacent sides of an
equilateral triangle as shown below.

For second approximation we repeat the procedure four times to draw a Koch curve.
The curve can be further extended by forming more number of approximations.
The curve does not fill any area. As well the Koch curve does not much deviate from its
original shape.

Computer Engineering Group

Page 18 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

Q.5.
a.

Attempt any FOUR of the following.


( 4 x 4 = 16)
Describe features of GUI
(1 M for each feature, Consider any 4 )
Ans: The graphical user interface, or GUI, is a computer interface that uses graphic icons and
controls in addition to text.
Features of GUI
1. Pointer: A symbol that appears on the display screen and that you move to select
object and commands.
2. Pointing device: A device, such as a mouse or trackball, that enables you to select
objects on the display screen.
3. Icons: Small pictures that represent commands, files or windows. By moving the
pointer to the icon and pressing a mouse button, you can execute a command or
convert the icon into a window.
4. Desktop: the area on the display screen where icons are grouped is often referred to
as the desktop because the icons are intended to represent real objects on a real
desktop.
5. Windows: You can divide the screen into different areas. In each window, you can run
a different program or display a different file.
6. Menus: Most graphical user interfaces let you execute commands by selecting a choice
from a menu.
b. Describe any one of graphics standards.
(Consider any one for 4 M)
Ans: 1. CORE
2. Programmers Hierarchical Interactive Graphical Standard (PHIGS)
3. Initial Graphics Exchange Standard (IGES)
4. Computer Graphics Metafile Standard (CGM)
5. Virtual Device Metafile (VDM)
6. Virtual Device Interface (VDI)
PHIGS: PHIGS (Programmer's Hierarchical Interactive Graphics System) is an API standard for
rendering 3D computer graphics, at one time considered to be the 3D graphics standard for
the 1990s. Instead a combination of features and power led to the rise of OpenGL, which
became the most popular professional 3D API of the 1990s. PHIGS is still widely used in
the computer games and film industries.
PHIGS was available as a standalone implementation (examples: Digital Equipment
Corporation's DEC PHIGS, IBM's graPHIGS, Sun's SunPHIGS) and also used with the X
Window system, supported via PEX, the "PHIGS Extension to X". PEX consisted of an
extension to X, adding commands that would be forwarded from the X server to the PEX
system for rendering. Workstations were placed in windows typically, but could also be
forwarded to take over the whole screen, or to various printer-output devices.
PHIGS was designed in the 1980s, inheriting many of its ideas from the Graphical Kernel
System of the late 1970s, and became an ANSI (ANSI X3.144-1988), FIPS (FIPS 153) and
then ISO standard (ISO/IEC 9592 and ISO/IEC 9593) by 1989. Due to its early gestation,
the standard supports only the most basic 3D graphics, including basic geometry and
Computer Engineering Group

Page 19 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

meshes, and only the basic Gouraud, "Dot", and Phong shading for rendering scenes.
Features considered "standard" today, notably texture mapping, were not supported, nor
were many machines of the era physically capable of it (at least in real-time).
IGES:The Initial Graphics Exchange Specification (IGES) (pronounced eye-jess) is a file format
which defines a vendor neutral data format that allows the digital exchange of information
among Computer-aided design (CAD) systems.
The official title of IGES is Digital Representation for Communication of Product Definition
Data, first published in January, 1980 by the U.S. National Bureau of Standards as NBSIR
80-1978. Many documents (like early versions of the Defense Standards MIL-PRF28000 and MIL-STD-1840) referred to it as ASME Y14.26M, the designation of
the ANSI committee that approved IGES Version 1.0.
Using IGES, a CAD user can exchange product data models in the form of diagrams, wire
frame, freeform surface or solid modelling representations. Applications supported by IGES
include
traditional engineering
drawings,
models
for
analysis,
and
other manufacturing functions.
An IGES file is composed of 80-character ASCII records, a record length derived from
the punched card era. Text strings are represented in "Hollerith" format, the number of
characters in the string, followed by the letter "H", followed by the text string, e.g.,
"4HSLOT" (this is the text string format used in early versions of the FORTRAN language).
Early IGES translators had problems with IBM mainframe computers because the
mainframes used EBCDIC encoding for text, and some EBCDIC-ASCII translators would
either substitute the wrong character, or improperly set the Parity bit, causing a misread.
Here is a very small IGES file from 1987, containing only two POINTS (Type 116), two
CIRCULAR ARC (Type 100), and two LINE (Type 110) entities. It represents a slot, with
the points at the centers of the two half-circles that form the ends of the slot, and the two
lines that form the sides.
CGM:The Computer Graphics Metafile (CGM) is the International Standard for storage and
exchange of 2D graphical data. Although initially a vector format, it has been extended in 2
upwardly compatible extensions to include raster capabilities and provides a very useful
format for combined raster and vector images.
A metafile is a collection of elements. These elements may be the geometric components
of the picture, such as polyline or polygon. They may be details of the appearance of these
components, such as line colour. They may be information to the interpreter about how to
interpret a particular metafile or a particular picture. The CGM standard specifies which
elements are allowed to occur in which positions in a metafile.
CGM also has profile rules and a Model Profile to attempt to solve the problem of flavours
of standards. 4 Internationally Standardised Profiles (ISPs) have been developed for CGM.
CGM has been accepted as a MIME data type.

Computer Engineering Group

Page 20 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

Type

Metafile

Colors

Unlimited

Compression

RLE, CCITT Group3 and Group4

Maximum Image Size

Unlimited

Multiple Images Per File Yes


Numerical Format

NA

Originator

ANSI, ISO

Platform

All

Supporting Applications Too many to list


CORE:The 3D Core Graphics System (a.k.a. Core) was the very first graphical standard ever
developed.
A
group
of
25
experts
of
the ACM Special
Interest
Group SIGGRAPH developed this "conceptual framework". The specifications were
published in 1977 and it became a foundation for many future developments in the field
of computer graphics.
c. What is open GL? Give basic drawing primitives of open GL. Enlist Features of open
GL.
(For definition 2 M for primitives 1 M and for features 1 M)
(Question is out of syllabus and any relevant answer mark should be given)
Ans: OpenGL is a software interface to graphics hardware. This interface consists of about 150
distinct commands that you use to specify the objects and operations needed to produce
interactive three dimensional application
Basic drawing primitives of open GL
Points
Lines
Polygon
Triangle
Quad
Quad strip
Triangle strip
Triangle fan
Features of OpenGL
Geometric Primitives
Colour coding
Viewing and Modeling
Texture mapping
Materials lighting
Computer Engineering Group

Page 21 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

Double buffering
Anti-aliasing
Z-buffering
Atmospheric effects
d. Describe shearing transformation.
(For Diagram 1 M and Description 3 M)
Ans: It is a transformation which slants or bends an object to specified direction. There are two
types of shearing transformation available in computer graphics. One which slants x
coordinate values is known as X shearing and one that slants y coordinate values is known
as Y shearing. Irrespective of shearing only one co-ordinate is change its coordinate and
other values are same.
X-Shearing:It is a process by which x coordinates are change to specified direction. In X shearing the
values of y coordinates are kept same and values of x coordinates are change as a result
of which vertical lines are tilt to right or left which results into slanting of entire object to one
direction i.e. horizontally only.

Fig Before Shearing of Object

Fig After Shearing of object

Fig gives an idea about Y-shearing operation in computer graphics. Fig. gives an object
without shear operation on it object look like a rectangle. When X-shearing operation is
used on it object get slanted towards horizontally only. Comparing objects in both figures
the base point is remains same just object gets slanted. The matrix for X-shearing is given
by

X_sh =

Computer Engineering Group

1
Shx

0
1

Page 22 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

Y Shearing: It is a process by which y coordinates are change to specified direction. In Y shearing the
values of x coordinates are kept same and values of y coordinates are change as a result
of which horizontal lines are slanted to upward or downward which results into slanting of
entire object to vertically only.

Fig Before Shearing of Object

Fig After Shearing of object

Fig. gives an idea about Y-shearing operation in computer graphics. Fig gives an object
without shear operation on it object look like a rectangle. When Y-shearing operation is
used on it object get slanted towards vertically only. Comparing objects in both figures the
base point is remains same just object gets slanted similar X-shearing.

Y_sh =

1
0
ShY 1

e. Write C-code for translation transformation of 2D object.


(Step Marks to be given 4 M )
Ans:

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm=DETECT,tx,ty;
clrscr();
printf("\nEnter Translation factors (TX and TY)");
scanf("%d%d",&tx,&ty);
initgraph(&gd,&gm,"D:\\TC\\BGI");
line(100,100,200,200);
getch();
line(100+tx,100+ty,200+tx,200+ty);
getch();
}

Computer Engineering Group

Page 23 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Q.6.
a.
Ans:

Subject Code: 12112

Attempt any FOUR of the following.


( 4 x 4 = 16)
(Fractal line 2 M, Fractal surfaces 2 M)
Describe fractal lines and fractal surfaces.
Generally, object which is having smooth surface and regular shape are described by using
equation but natural object such as mountain, tree, waves and clouds have irregular
shapes and it is very difficult to draw these shapes by using normal equation.
There are may method of modeling these object but one of the important is by using fractal.
From certain distance we will see a line as a simple, quite smooth line but as we go near to
that lines. It will appear more rough.

We can draw coastline or lightning bolt by fractal lines. But if we want to draw a 3D object
like, say mountain, then we have to use fractal surfaces. The concept of fractal lines can be
extended to generate fractal surfaces. There are many by which we can do this. Here we
are explaining a method which is based on triangle.

Computer Engineering Group

Page 24 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

The fractal surfaces can be generated by performing following steps:


We will use fractal line algorithm to each edge of the triangle.
Compute its halfway point by the same logic as that of fractal lines.
Connect these halfway points by line segments. By doing this we are now having four
small triangles. Now we can call this procedure recursively to each of small triangle until
the triangles becomes too small.
b.
Ans:

Write short note Bezier curve.


(For Diagram 1 M, Description 3 M)
Bezier curve is an approach of constricting curve. It is determined by defining a polygon.
Bezier curve have properties that makes it highly useable and ease for curve design. These
properties are also easy to implement. Hence Bezier curve is widely available in various
CAD systems. This curve offers good flexibility and also avoids complex calculation. In this,
four points are used to give complete curve. There is no addition of intermediate points like
B-spline curve and also smoothly extensions of Bezier curve by picking four more points
and construct second curve which can be join to first one.

Subsection of Bezier curve

CD

C
BCD

BC

ABCD
ABC

AB
A
Fig. Subsection of Bezier Curve

Computer Engineering Group

Page 25 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

Algorithm: Step 1: Get four control points A (XA, YA), B (XB, YB), C (XC, YC), D (XD, YD)
Step 2: Divide the curve represented by points A, B, C, and D in two sections
XAB = (XA + XB) / 2;
YAB = (YA + YB) / 2;
XBC = (XB + XC) / 2;
YBC = (YB + YC) / 2;
XCD = (XC + XD) / 2;
YCD = (YC + YD) / 2;
XABC = (XAB + XBC) / 2;
YABC = (YAB + YBC) / 2;
XBCD = (XBC + XCD) / 2;
YBCD = (YBC + YCD) / 2;
XABCD = (XABC + XBCD) / 2;
YABCD = (YABC + YBCD) / 2;
Step 3: Repeat step 2 for section A, AB, ABC, and ABCD and section BCD, CD, D.
Step 4: Repeat step 3 until section so short that they can be replace by straight lines.
Step 5: Replace small sections by straight lines.
Step 6: Stop.
c.

Ans:

How category of line is find out far its visibility using region code in cohen
Sutherland line clipping algorithm?
(For region code 2 M and Description 2 M)
Identify category of line and identify those lines which intersect the clipping window
category 3 and hence need to be clipped.
Assign a 4-bit code called as region code to each endpoint of the line. These codes identily
the location of the point relative to the boundaries of the clopping window. Compute 4-bit
code. Starting from leftmost bit, each bit of code is set to 1 according to following scheme,
Bit 1: 1, if point is above window, i.e y > WT. (Ymax)
Bit 2: 1, if point is below window, i.e y < WB. (Ymin)
Bit 3: 1, if point is right of window, i.e x < WR (Xmax)
Bit 4: 1, if point is left of window, i.e x < WL. (Xmin)
All bits 0 i.e. 0000 if point is inside window.

1001

1000

1010
WT

0001

Window
0000

0010

0101

0100

0110

WB

WL

WR
Four bit region codes

Computer Engineering Group

Page 26 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

Since codes are assigned to both end points of line them.


Category1. The line is visible if region codes of both end points of line are 0000. i.e.
completely inside window. Here accept whole line to display.
Category2. The line is not visible i.e. line completely outside of window, if bitwise logical
AND of codes of both end points is not 0000 and thus reject the line and do not display.
Category3. If bitwise logical AND of the region codes of both end points is 0000 then it is a
line intersecting boundaries and needs clipping and pass this line to phase 2 for clipping.
d.
Ans:

e.
Ans:

Explain viewing transformation and normalisation transformation.


(Viewing 2 M, Normalisation 2 M)
Viewing transformation Pictures are defined any stored into memory using any
convenient Cartesian co-ordinate System is called as World Co-ordinate Systems(WCS).
When picture is to be displayed on display device it is measured in physical Device Coordinate System (PDCS) corresponding to the display device. Therefore to display any
image on screen, we need to map it from stored World Co-ordinate Systems to appropriate
Physical Device Co-ordinate system (PDCS). Therefore in general the process of mapping
of picture from World Co-ordinate systems to Physical Device Co-ordinate system is
referred as Viewing Transformation.
Normalisation transformation- It maps world coordinate system to normalized device
coordinate system (NDCS), AS different display devices have different screen sizes
measured in pixels we need to make our program display device independent. This display
device independent unit system is called as normalised device coordinate system.
Describe B-spline curve.
(For Diagram 1 M and Description 3 M)

B-Spline Curve Generation:A B-spline is a spline function that has minimal support with respect to a given degree,
smoothness, and domain partition. B-splines. A fundamental theorem states that every
spline function of a given degree, smoothness, and domain partition can be uniquely
represented as a linear combination of B-splines of that same degree and smoothness, and
over that same partition.
In the computer science subfields of computer-aided design and computer graphics,
the term B-spline frequently refers to a spline curve parameterized by spline functions that
are expressed as linear combinations of B-splines (in the mathematical sense above). A Bspline is simply a generalization of a Bzier curve

Computer Engineering Group

Page 27 of 28

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC 27001 2005 Certified)

WINTER 2012 EXAMINATION

Model Answer
Subject Title: Computer Graphics

Subject Code: 12112

Fig B-Spline Curve


Advantages of B-Spline:
1. The Degree of a B-Spline polynomial can be set independently of the number of control
points (with certain limitation)
2. B-Spline allow local control over the shape of spline curve of surface the trade-off is that
B-Spline are more complex then Bezier Spline
f.
Ans:

Write DDA arc generation algorithm.


(All correct steps 4 M)
Algorithm:Step 1
Read the center of a curvature say (x0 , y0)
Step 2
Read the are angle say
Step 3
Read the starting point of the arc i.e. (x,y)
Step 4
Calculate d
d = Min (0.01, 1/(3.2 x (|x-x0|+|y y0| )))
Step 5
Initialise Angle = 0
Step 6
While (Angle < )
Do
{ Plot (x, y)
X = x (y - y 0) x d
Y = y + (x -x 0) x d
Angle = Angle + d
}
Step 7
Stop.

Computer Engineering Group

Page 28 of 28

Das könnte Ihnen auch gefallen