Professional Documents
Culture Documents
(Autonomous)
(ISO/IEC 27001 2005 Certified)
Model Answer
Subject Title: Computer Graphics
Q.1
a.
Ans:
Page 1 of 28
Model Answer
Subject Title: Computer Graphics
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.
Ans:
Page 2 of 28
Model Answer
Subject Title: Computer Graphics
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:
Page 3 of 28
Model Answer
Subject Title: Computer Graphics
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
Page 4 of 28
Model Answer
Subject Title: Computer Graphics
b.
Ans:
[ 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:-
Page 5 of 28
Model Answer
Subject Title: Computer Graphics
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
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
0 0
Sy 0 0
0 Sz 0
[S X
x
SyY SzZ 1
Model Answer
Subject Title: Computer Graphics
#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();
}
Page 7 of 28
Model Answer
Subject Title: Computer Graphics
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.
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.
Page 8 of 28
Model Answer
Subject Title: Computer Graphics
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.
Page 9 of 28
Model Answer
Subject Title: Computer Graphics
ii.
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
Electronic gun
Analog
Signal
Screen
Page 10 of 28
Model Answer
Subject Title: Computer Graphics
f.
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
Page 11 of 28
Model Answer
Subject Title: Computer Graphics
Q.3.
(4 x 4 = 16)
Page 12 of 28
Model Answer
Subject Title: Computer Graphics
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.
Page 13 of 28
Model Answer
Subject Title: Computer Graphics
Page 14 of 28
Model Answer
Subject Title: Computer Graphics
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.
Page 15 of 28
Model Answer
Subject Title: Computer Graphics
Q.4.
(2 x 8 =16)
Page 16 of 28
Model Answer
Subject Title: Computer Graphics
Page 17 of 28
Model Answer
Subject Title: Computer Graphics
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.
Page 18 of 28
Model Answer
Subject Title: Computer Graphics
Q.5.
a.
Page 19 of 28
Model Answer
Subject Title: Computer Graphics
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.
Page 20 of 28
Model Answer
Subject Title: Computer Graphics
Type
Metafile
Colors
Unlimited
Compression
Unlimited
NA
Originator
ANSI, ISO
Platform
All
Page 21 of 28
Model Answer
Subject Title: Computer Graphics
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 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 =
1
Shx
0
1
Page 22 of 28
Model Answer
Subject Title: Computer Graphics
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. 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
#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();
}
Page 23 of 28
Model Answer
Subject Title: Computer Graphics
Q.6.
a.
Ans:
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.
Page 24 of 28
Model Answer
Subject Title: Computer Graphics
CD
C
BCD
BC
ABCD
ABC
AB
A
Fig. Subsection of Bezier Curve
Page 25 of 28
Model Answer
Subject Title: Computer Graphics
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
Page 26 of 28
Model Answer
Subject Title: Computer Graphics
e.
Ans:
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
Page 27 of 28
Model Answer
Subject Title: Computer Graphics
Page 28 of 28