CG PDF
CG PDF
VIDYAVAHINIFIRSTGRADECOLLEGE
COMPUTER GRAPHICS
6th Sem BCA
E-Mail:[email protected]
Website:www.vidyavahini.org/bca
ntroduction to Graphics
Chapter 1
Computer graphics is a picture that is generated by a computer; it converts a scene to an image or
the process of transformations, shading, and animation of the image.
• In the 1950‟s the first computer driven display was used to generate simple pictures, this
display used Cathode Ray Tube(CRT).
• Then “Ben Laposky” created the first graphic images generated by an electronic machine.
• In the 1960‟s beginning of modern interactive graphics and vector graphics .One of the
problem was cost and inaccessibility of machines.
• In the 1980‟s output are built in raster graphics, bitmap image and pixel. Pc costs decrease
drastically.
• In 1990‟s , since the introduction of VGA[Video Graphics Array] and SVGA[Super Video
Graphics Array], pc could easily display the images and movies. 3D image become the main
advances and it helps in cinematic Graphics applications.
8. Information Graphics
9. Virtual Reality.
Computer Aided Design (CAD): it is a type of computer based tool used for drafting and
designing. CAD is useful in various designing fields such as architecture, mechanical and
electrical, automobiles, aircrafts, spacecrafts, textiles etc.
Presentation Graphics: it is used to produce bar charts, pie charts, line graphs, surface
graphs and other displays. Computer Graphics is applicable in financial, statistical,
mathematical, scientific data for research reports and other types of reports.
Computer Art:computer graphics methods are widely used in both fine art and commercial
art applications, artists use a variety of computer methods including special purpose hardware,
paint brush, animations, CAD etc.
Entertainment:computer Graphics methods are also used in making motion pictures, video games,
television shows, music videos etc.
Educational and Training: it is used in education and training. Computer generated models of
physical, financial and economic systems are often used, which helps trainee to understand the
operation of the system.
Image processing: it is a technique used to modify or interpret existing pictures. In image processing
methods we first digitize a photograph or other picture into an image file.
Information Graphics: it is also called as info graphics are Graphics Visual representation of
information, data or knowledge, these Graphics presents complex information quickly and
clearly such as signs, maths, generalism, technical writing and education.
Virtual Reality: it is a term that applies to computer simulated environments that can simulate places
in the real world as well as in imaginary world.
b) Type of Interaction: it determines the user control over the object and its image.
c) Role of Pictures: CAD application is used to drawing is just a representation of the object
being designed or analyzed.
d) Relationship b/w objects and their pictures: this category arises from the logical and
temporal relationship b\w objects and their pictures.
Graphics Software:
It is a program or collection of programs that enable a person to manipulate visual images on a
computer. Graphics software are classified into two types
3) Television Monitor
00000000000000000000000
00000010000000000000000
10100000000000000001000 Display controller
00101010000000000000000
00000000000100101000000
Frame Buffer: the displayed image is stored as a matrix of intensity values (stores the
picture definition in terms of bytes).
It consists of 3 components
1) Frame Buffer or Digital memory
2) Display controller or video controller
Display Controller:a special purpose processor called display controller is used to control the
operation of the display device. It passes the contents of the frame buffer to the monitor. The
image must be passed repeatedly to the monitor 30 or more times a second to maintai n
constant picture on the screen.
Television Monitor:the Display controller reads the byte of data from the frame buffer and converts
its zero‟s and one‟s (0‟s & 1‟s) into corresponding video signal then the signal is transferred to the
TV monitor producing a black and white pattern on the screen.
The electron gun generates a beam of electrons, which passes through focusing and deflection
system that direct the beam towards specified positions on the phosphor coated screen.
The phosphor emits a small spot of light at each position strikes by the electron beam.
Focusing system consists of two metal plates mounted perpendicular to the beam axis with holes
at their center through which the beam pass. It is maintained at high relating potential to
accelerate the beam to necessary velocity.Deflection system contains a set of coils mounted at the
neck of the tube. The horizontal deflection plates controls the vertical deflection and the vertical
deflection plates controls the horizontal deflection.
Phosphorus used in graphic display, the electric energy is converted to light when the electron
beam fall on the phosphor coated screen
2. Persistence: how long small spots continue to emit light after the beam is moved or
removed is called persistence. Lower persistence requires higher refresh rate
and it‟s good for animation. Higher persistence is useful for displaying complex static
picture.
4. Aspect ratio: ratio between vertical points and horizontal points necessary to
produce equal length lines in both directions on the screen.
Aspect ratio=3/4
Vertical line with 3 points is equal in length to horizontal line of 4 points(pixels)
The electron beam is fall across the screen are row at a time from top to bottom. As the
electron beam moves across each row, the beam intensity is turned on and off depends on the
picture definition.
Picture definition is stored in a memory area called the frame buffer. This memory area holds
the set of int ensity values for all screen points. Stored intensity values are then retrieved from
the buffer and painted on the screen one row at a time. Each screen point is referred to as a pixel
(or) pel.
A bit value of 1 indicates that the electron beam is to be turned on at that position and a value
of 0 indicates that the beam intensity is to be off. Refreshing on raster scan display is carried
out at the rate of 60 to 80 frames/second. At the end of each scan line the electron beam returns
to the left side of the screen to begin displaying the next line. Returning to left screen after
refreshing each scan line is called horizontal retrace. Similarly when an electron beam returns to
the top left corner of the screen to begin next frame is called vertical retrace.
Advantages:
(i) Images can be displayed with realistic and includes 3D effects also.
(ii) The cost is very low compared to other devices.
Disadvantages:
(i) Resolution is low.
(ii) The lines produced are zigzag
(iii) High speed display application and animations cannot use this technique.
In Random scan display a CRT as the electron beam directed only to the parts of the screen
where a picture is to be drawn. It draws a picture one line at a time. Picture definition is now
stored as a set of the drawing commands in area of memory referred t o as the refresh display
(or) refresh buffer. After all line drawing commands have been processed the electron beam to
the first line command in the list. Random scan systems are designed for line drawing
applications and cannot display realistic images.
Advantages:
Disadvantages:
CRT Monitors displayed color picture by using combination of phosphors that emit different coloured
light color RT monitors used two methods.
Random scan system technique is used in beam penetration method for displayed colour
pictures.There are 2 layers of phosphors one is green phosphor coated on to the inside of the
CRT Screen and other one is the Red phosphor coated behind the green phosphor.Thecolor
depends on the electron beam speed penetrates. A beam of slow electrons excites(strikes) only
the red layer to produce a red color. A beam of very fast electron penetrates through the red
layer and excites the green layer to produce green color.
An intermediate beam speed, a combination of red and green light to display two colors like Orange
and Yellow.
Disadvantages:
Shadow – mask method produce a much wider range of colors than the beam penetration
method. A shadow-mask CRT has 3 electron – Gun produce 3 colors with the help of Red, Blue
and Green electron beam.
A Grid called a shadow– mask is just placed behind the phosphor coated screen. The 3 electron
beam are deflected and focussed as a group on to the shadow mask contains a series of holes
aligned with the phosphor dot pattern.
When the 3 electron beams pass through a hole in the shadow– mask, they activate a dot triangle
which appears as a small coloured dot on the screen. Different colours are displayed by varying
the intensity levels of the 3 electron beam. White produces when all three dots with equal
intensity. Yellow produced with green and red dots only. Magenta is produced with blue and
red dots. Cyan produced when blue and green are activated equally.
• Display processors are typically designed to interface with interactive input devices.
• Cartesian co-ordination is referred in frame buffer location and corresponding screen positions.
• An application program is input and stored in the system memory along with a graphics packages.
• Graphics command in the application program is translated by the graphics package into a display
file stored in the system memory.
• This display file is then accessed by the display processor to refresh the screen.
• The display processor is referred as dis play processor unit (or) graphics controller which goes
through each command in the displayed file during every refresh cycle.
Instruction Set
The display processing unit (DPU) or Graphics controller has an instruction set and instruction
address regis ter, which goes through the classic instruction fetch, decode and execute cycle
found in any computer.
In order to provide a flicker free display the display processor must execute its program 30 to
60 times/sec.Graphic packages create a display program and tell the DPU where to start the
program. DPU then execute the display program until it is told to stop by graphics packages.
JUMP instruction at the end of display program transfers control back to its start, so that display
continues to start without CPU intervention.
Color Mapping
A color model is an abstract mathematical model describing the way colors can be represented
as Tupiles of numbers, typically as 3 (or) is values (or) color components. A color model is a
specification of 3D coordinate system.
Questions:
1. What is staircase effect?(1M,DEC 2011)
2. Define the terms refresh rate and aspect ratio. (1M,DEC 2011)
3. Explain any five applications of computer graphics.(5M,DEC 2011)
4. Explain functioning of CRT with a neat diagram.(9M,DEC 2011)
5. Explain RGB and CMY color models.(5M,DEC 2011)
6. Explain the concept of interactive graphics.(3M,DEC 2011)
7. Explain application computer graphics in education and health care.(3M,DEC 2011)
8. Discuss the working of a Beam penetration CRT, with a neat diagram.(5M,DEC 2011)
2 Chapter
Points and Lines
Point plotting techniques are based on Cartesian co-ordinate system where they are referred to
by their „x‟ and „y‟ co-ordinates.
Line Drawing Algorithms: The criteria required to generate straight lines are (i)
Line should appear straight.
(ii) Line should terminate accurately.
(iii) Line should have constant density.
(iv) Line density should be independent of line length and angle. (v) Line should draw
rapidly.
b = Y1– mx1
The „Y‟ intercept „b‟ is
dy else
steps = dx
For any given x interval x along a line, we compute corresponding line interval „
y‟
The two end points are represented as (x1, y1) & (x2, y2)
Algorithm
Step 1: Input two end points (x1, y1) & (x2, y2)
Step 2: Calculate the constants dx &dy
x1nc = dx | Steps
y1nc = dy | Steps
Step 5: (for loop) i = 1 up to steps
Plot pixel (x, y, RED)
x = x + xinc
y = y + yinc
End for
Write a program to construct a line using DDA Algorithm. # include<iostream.h>
# include<conio.h>
# include<graphics.h>
Void main ( ) {
int x1, y1, x2, y2; Clrscr
()
Cout<<“enter first end point”; Cin>> x1>>
y1;
Cout<<“enter second end point”; Cin>> x2>>
y2;
initgraph (&gd, &gm “ ,C: \\ tc \\bg::”);
Clear device ( ); dda line (x1, y1, x2,
y2);
getch ( ); close
graph ( );
}
Void ddaline (int x1, y1,int x2, int y2)
{ int dx, dy, steps, i;
float x inc, y inc, x, y;
dx = abs (x1 – x2); dy
= abs (y1 – y2); if(dx
<dy)
Steps = dy;
else Steps =
dx;
Xinc = dx / steps; Yinc
= dy / steps; for
(i=1;i<= steps; i++)
{
Put pixel (x, y, RED);
X = x + xinc;
Y = y + yinc;
Put pixel (x, y, RED);
}
|| End of function.
Bresenhams algorithm is designed such that each interaction changes one of the coordinate values by
+ 1 (or) – 1.
Algorithm: let (x1, y1) (x2, y2) = (10, 10) (15, 15)
Step 1 : Input two end points (x1, y1) & (x2, y2)
Step 2 : calculate dx = |x1
– x2| dy = |y1 –
y2|
Step 3 : Starting decision Parameter
P= 2dy – dx.
Step 4 :if (x1< x2)
x= x1 Y= y1
Xend = x2
Else
X = X2
Y = Y2
Xend = X1
Step 5 :while(x<_xend)
Putpixel(x,y,RED)
if(p>0)
y++;
p=p+2(dy-dx)
else
p=p+2dy
x++
step 6: stop
• X inc and Y inc are calculated The increment value of X and Y is always based on the formula.
Unity.
Circle Generations
A circle is defined as the set of points that are all at a given distance „r‟ from a
centre position (Xc, Yc). (x-x c) 2+(y-yc)2=r2
The distance relationship is written as
In Bresenhams algorithm, the decision parameter decides the closest point lying on the
circumference of the circle. For a given radius „r‟ and centre position (Xc, Yc). We calculate
pixel positions around the circle with the centre at a Origin.
Algorithm:
Step1: input Xc, Yc and radius r
Step 2: x=0; y=r; p=1-r;
While(x<y)
{
If(p<0)
P=p+2x+1
X++
Plotpoints(Xc,Yc,X,Y)
}
Step3:stop
Void plotpoints (intXc, intYc,intX,int Y)
{
Putpixel(Xc+X,Yc+Y,RED);
Putpixel(Xc-X,Yc+Y,RED);
Putpixel(Xc+X,Yc-Y,RED);
Putpixel(Xc-X,Yc-Y,RED);
Putpixel(Xc+Y,Yc+X,RED);
Putpixel(Xc-Y,Yc+X,RED);
Putpixel(Xc+Y,Yc-X ,RED);
Putpixel(Xc-Y,Yc-X RED);}
Ellipse Generating Equation (Algorithm (Bresenhams)
An ellipse is defined as the set of points such that the sum of the distance from 2 fixed positions
is the same for all points. The ellipse has 2 access:
i) Major axis (rx) ii) Minor
axis (ry) Equation of elipse:
(x-xc/rx)2+(y-yc/ry)2=1
Where((xc.yc)=(0,0) Region
1:
We can start at position (O, ry) and step Clockwise along the elliptical path in the first quadrant.
Region 2 :Alternatively we can start at (rx, o) and select points in a counter clockwise order.
Line Attributes:
The attributes of a straight line segment are
i) Type ii) Width
iii)
Color (i)
Line
Type :
Solid Line ___________
Dotted line .......................
Dashed line -----------------
Dashed – dotted line -.-.-.-.-.-.-.-.-.-
Lines can be generated by setting the length and spacing. Set the line type attribute
with the command “setlinetype (lt)”; where lt = 1, 2, 3, 4 having solid, dotted,
dashed, dashed-dotted resp.
(ii) Round Cap : the arcs are centered on the end points of the line.
(iii) Square Cap : it extends the line and adds butt cap positioned half of line width beyond
the specified end points.
Line Color:
Set the line color attribute with the command set Polyline ColorIndex (lc) Where,
lc is a non-negative values to allow color choices. Eg: Set Line type
(2);
Set Line width Scale Factor (2);
Set Polyline Color Index (4);
Area Filling:
The solid color filled (or) a pattern filled polygon is a standard o/p primitive of a graphics package.There
are 2 ways of area filling on rasters system.
(i) Using boundary definitions, identifying which pixels belongs to the interior of the area
specified.
(ii) Starting from a point inside the area and painting outwards until the boundary definition is
encounter.
• For each scanline locate the intersection of the scanline with the edges.
• When a scanline passes through a vertex, it intersects 2 polygon edges at that point and fills the
color.
Fill Styles:
There are 3 basic fill styles.
(i) Hallow with a color border.
(ii) Filled with a solid color.
(iii) Filled with specified pattern (or) design.
Font Options are available as set of Grip patterns (or) as character sets designed with
polyline curves.
2. Character Height : It is defined as the distance between the base line and cap line of characters.
Doubling the height also doubles the character width and height between the characters. Eg:
Heigh 1
Height2
Height3
3. Character Width:The width of text can be set with the function “set Character Expansion Factor
(cw);” Where cw is a positive value.
The height dosenotchange by this attribute setting Eg:
width 1.0
W i d t h 2. 0
W i d t h 3.0
4. Character Spacing: The spacing between the characters can be changed with
“setCharacter Space (cs);”
Where cs can be assigned any real value.
Eg: spacing o.o
S p a c i n g o.5
S p a c i n g 1. 0
5. Orientation:The Orientation for a displayed character string is a set according to the direction of
the character up vector. “setCharacter Up Vector (upvect);” Where upvect having (x,y) values.
if x = 1 & y = 1 i.e., (1, 1), the text (or) string will be displayed in 45 angle.
Quetions:
2D TRANSFORMATION
Chapter 3
Creating an image is the first step of a Graphics system. The second step is to include variety of
transformations.
“Transformationis the ability to rearrange a picture so that its details appear more clearly and modifying
the picture.”
i) Translation. ii)
Scaling. iii)
Rotation.
(i) Translation: An object is re-positioning (moving) from one place to another place is known as
translation.
A 2 – dimensional point can be translated by adding translation distances tx and ty to the original co-
ordinate position (x, y), after moved the object the new positions are (Xnew, Ynew).
The translation distance pair T(tx, ty) is called the translation vector (or) shift vector.
p Pnew
pnew= P+T
(ii) Scaling:It is the ability to change the size of an image (or) object each vertex of an object has the
scaling factor Sr and Sy to produce the transformed co-ordinates.
p Pnew
Pnew= P*S
Xnew=x.Sx
Ynew=y.Sy
Any positive numeric value can be assigned to scaling value Sx&Sy value greater than one
produced enlarge object, value lesser than one decreases the size of the object and if Sx = 1 and
Sy = 1, the object size do not change Pnew = P.S.
(iii) Rotation: Rotation is the ability to repositioning an image along a circular path in the (x,
y) plan. By specifying the angle of rotation 𝜽 and the position (Xr, Yr) of the rotation point
which the object is to be rotated.
Xnew=rcos(𝜱 + 𝜽) Ynew=rsin(𝜱
+ 𝜽)
angle.
1. Translation
Pnew = P+T
2. Scaling
Pnew = P * S
3. Rotation
Other Transformations
1. Shear.
2. Reflection.
1. Shear: The shape of an object can be distorted by sliding the internal layers of the original
object is known as shear. Two common shearing transformations are (i) Shift X values.
Xnew=X+ Shx.Y
Ynew = Y
` Xnew=X
Ynew = Y+Shy.X
The matrix representation is
2. Reflection:
Composite Transformations.
When a transformation is applied more than once on the particular object (or) image then we call
that as composite transformation.
(a) Translation
In order to apply two successive translations on an object, we can first perform the
concatenation of the translation matrices and then apply the composite matrix to the
coordinate points.
T(tx1,ty1).T(tx2,ty2)=T(tx1+tx2,ty1+ty2)
(b) Scaling :
To apply 2 successive scaling to an object, the concatenation of scaling matrices is performed and
then the composite matrices is applied to the co-ordinates points.
S(Sx1,Sy1).S(Sx2,Sy2)=S(Sx1.Sx2,Sy1.Sy2)
(c) Rotation
To apply 2 rotations to an object, we can first perform the concatenation of rotation matrices and
then apply the composite matrices to the co-ordinate point
. =
“Raster functions that manipulated rectangular pixel arrays are referred as raster operations,
moving a block of pixels from one location to another is also called as block transfer of pixel
values.”
Questions:
1. Give scaling factors to double the object size.(1M,DEC 2011)
2. Give matrix representation for reflection about X and Y axes. (1M,DEC 2011)
3. Explain 2 dimensional translations. (1M,DEC 2011)
4. Explain scaling transformation.(1M,DEC2011)
5. Give raster method for transformation. (5M,DEC 2011)
6. Explain the 2D composite transformation for scaling transformation.(5M,DEC2011)
7. Explain shear Transformation?
8. What do you mean by composite transformation? How it is useful?
Chapter 4 Windowing
& Clipping
Normally graphical packages allow a user to specify what portion of the image is to be displayed
and where the image is to be displayed.
A convenient co -ordinate system which is used to define a reference frame of the picture forms the
world co-ordinates.
“A rectangular area of the display device, which will contain the picture to which a window is
mapped, is called a view port.”
The commands to set the window and view port areas from an application program may be defined as
set of pre-defined function.
Clipping
Whenever a window area is mapped onto a viewport, this results in the display of only
those parts of the picture within the window. All other portions of the picture which are outside
the window are discarded.
Clipping Operations
Types of Clipping
1. Point Clipping.
2. Line Clipping.
3. Text Clipping.
4. Area Clipping.
5. Curve Clipping.
1. Point Clipping
Clipping of points is done by comparing each point with the boundary of the rectangle
window, i.e., point clipping against a window specification is done by testing the
coordinate values to determine whether they are within the boundaries (or) not.
2. Line Clipping:
(i) Test whether the line segment lies completely inside the window.
(ii) Test whether the line segment lies completely outside the window.
(iii) If the line is neither completely inside nor outside the window, intersection calculations are
performed within the clipping boundaries.
(i) First determine whether the line lies entirely on the screen and if not whether it can be
rejected as lying entirely off the screen.
(ii) If it satisfies the 2 tests, then the line is divided into 2 parts and these 2 tests are applied
to each part.
The rejection test is done by extending the edges of the screen, so that they divide the space
occupied by the unclipped picture into 9 regions. Each of these regions has a 4 – bit code and
the 2 end – points of the line are assigned codes according to the regions.
Region codes
If the 4 – bit code for both end – points are zero then the line lies entirely on the screen. If the logical
intersection AND of the 2 codes is not zero then the line must lie off the screen.
If the line cannot be eliminated, it must be divided. This can be done by finding the point of intersection of
the line with one edge of the screen and discard the part that lies off the screen.
3. Text Clipping:
(a) String Clipping: If the complete string is inside the clip window boundary, then we it to a
viewport otherwise the string is discarded.
(b) Character Clipping: Here we discard only those characters that are not completely
inside the window boundary.
4. Curve Clipping:
The bounding rectangle for the curved object is first tested for ovelap (or) intersection
with the rectangular window. If the bounding rectangle for the curve is completely within the window
then the object is saved otherwise discarded.
If we want to clip a picture to the exterior specified region, i.e., all the parts outside the region
must be retained but within the window boundary region is discarded is known as blanking (or)
exterior clipping.
Line clipping technique can also be applied to clip hallow polygons. Polygon clipping can
be done by clipping each component line using line clipping technique.
The Sutherland – Hodgeman algorithm is based on the fact it is easy to click a polygon against a single
clipping edge.
The algorithm operates on the vertices of polygon, when each pair of vertices is passed to a window
boundary clipper. There are 4 possible techniques,
1. Left Clipper.
2. Top Clipper.
3. Right Clipper.
4. Bottom Clipper.
First left clipping is applied to the polygon starting from the intersection point, the outside
window boundary is discarded and the inside the window boundary will be saved. This procedure is
applied to the top clipper, right clipper and bottom clipper.
1. If the first vertex is outside the window boundary and the second vertex is inside the window
boundary, the intersection point of the polygon edge with the window boundary and the second
vertex is added to the output vertex list.
2. If both vertices is inside the window boundary, only the second vertex is added to the output vertex
list.
3. If the first vertex is inside the window boundary and the second vertex is outside, only the edge
intersection with the window is added to the output vertex list.
4. If both the input vertices are outside the window boundary nothing is added to the output vertex
list.
The line is divided at its midpoint into 2 shorter line segments. The clipping categories of the 2 new line
segment are next computed using the region.
Category 2: Lines are not visible and lines outside the window.
Category 3: Lien is again divided into shorter segments and apply these 3 categories.
The midpoint co-ordinates (Xm, Ym) of a line (x1,y1) and (x2,y2) are given by xm=(x1+x2)/2 In
the above picture, we can determine the 2 intersection points A1 and B1 With 5 bisections using
midpoint subdivision algorithm.
Questions:
Chapter 5 Three
Dimensional Displays
The conventional orientation for the co-ordinate axis in a 3 dimensional system is determined as follows.
1. Right handed System: If the thumb of right hand point in the positive Z direction, then the co
ordinates are called a right handed system.
2. Left handed System:If the thumb of left hand points a positive Z direction, then the coordinates
are called a left handed system.
The technique for achieving realistic images objects in 3 Dimensional Graphics System.
Projection can be defined as mapping of a point p(x, y, z) onto its image P (x, y, z) in the projection
plane (or) view plane.
1. Parallel Projection:
Parallel projection involves generating a view of a solid object by projecting points on the object
surface along parallel lines onto the display plane.
By selecting different viewing positions we can project visible points of the object on the display plane and
obtain different 2 – Dimensional views of the object.
2. Perspective Projection:
For generating a view of a 3D object, the points are projected onto the display plane
along converging lines. This makes the objects which are far away from the viewing position
to be displayed smaller than the objects with the same size. If the object si nearer to the viewing
position to be displayed.
For generating a view of a 3 D object, the points are projected onto the display plane
along converging lines. This makes the objects which are far away from the viewing position
to be displayed smaller than the objects with the same size. If the object isnearer to the viewing
position to be displayed larger.
Using perspective projection, the images displayed look more realistic, since that is the way our
eyes (or) the camera, forms images.
Intensity is to vary the intensity of lines according to their distance from the viewing position.
From the below the pic shows, an object with front lines highlighted and drawn wider than back
lines. The range of intensity brightness gradually decreases for lines far from the viewer.
3-Dimensional Transformations.
(i) Translation.
(ii) Scaling.
(iii) Rotation.
Translation:
In a 3 – D Co -ordinate representation, a point „p‟ (x, y, z) is translated to position p 1(x1,y1,z1) with the
matrix operation.
= +
Scaling
In a 3 – D co-ordinate representation, an object is scaled from the position (x, y, z) to the position
(x1,y1,z1) with the matrix operation.
Polygon Surfaces.
Any closed object can be classified as a polygon, i.e., any 3 – D object can be represented as a set of plain
polygon surfaces.
A 3 – D graphics object is generally represented using a set of surface polygons enclosing the
object interior. The object descriptions are stored as a set of surface polygons. Realistic images
can be produced by interpolating shaded patterns on the polygon surface.
Polygon Tables
A polygon surface is specified with a set of vertex co-ordinates and attributes parameters. The
information for each polygon is stored in data tables which are later used for processing display
and manipulation of the objects.
1. Geometric Table:It consists of vertex co-ordinates and parameters for identifying orientation of
polygon surface.
2. Attribute Table:it contains parameters specifying the degree of transparency, surface reflectivity
and texture of the object.
Another useful technique for solid modelling is to combine the volumes occupied by overlapping 3D
objects using set of operations. This method is called CSG.
It created a new object by applying the union, intersection and difference operation to two specified
objects.
(i) Union: A block and pyramid are placed adjacent to each other using union operation we obtain the
combined object.
(ii) Intersection: A block and a cylinder with overlapping volumes, using the intersection operation,
we can get the resulting solid object.
(iii) Difference: The solid is obtained with a difference operation by substracting overlapping volume
of the cylinder from the block.
Oct trees
Oct trees are hierarchical tree structures used to represent solid objects in a graphics system,
medical imaging and other applications requiring displace of object cross sections use oct tree
representation. The tree structure is such that each node corresponds to a region of 3D space. It
also provides a convenient method for storing information about object interiors.
A heterogeneous octant is sub divided into 8 parts, the corresponding data element in the node
points to the next node in the oct tree.
Fractal Geometry representations for objects are applied in many fields to describe the features of
natural phenomenon. In computer graphics we use fractal method to generate images of
natural objects and for viewing of various mathematical and physical systems.
Applications of Fractals
1. Fractal representations are used for modelling clouds, water, trees, plants, etc.,
2. Fractal patterns are also found in distribution of stars, moon, music, traffic flow, etc.,
Classification of Fractals.
Bezier Curves
P Bezier pioneered the use of computer modelling of surfaces in automobile design. His method has
been applied to define the outer panels of several cause marketed by Reyna
Bezier defines the curve p (u) in terms of the location (n + 1) control points pi as a blending function B
I, n (u)
A Bezier curve is a polynomial of degree, one less than the no. of control points used, 3 points, generate
a parabola, u points generate a cubic curve and so on.
There are many approaches that we can take to solve the problem of removing the parts of the
picture definition that are not visible from a chosen viewing position.
A simple object space method for identifying the back face of objects is based on the equation of
planeAx + By +Cz + D =0
Any point x, y, z specified in a right – handed system co -ordinate is on the inside of this plane if it
satisfies the inequality Ax + By + Cz + D < O.
A simple back – face test can be done by considering a normal vector „N‟ with Cartesian co
ordinates (a,b,c) in a right – handed system viewing along the negative Z, axis.
If C < O the polygon is a back – face since the normal vector points away from the viewing position.
Image space method is used to detect visible surface in depth buffer method, which compares surface
depth at each pixel position on the projection plane. This procedure is also referred to as Z – Buffer
method, since object depth is usually measured from the view plane along the Z – axis of a viewing
system.
2 Buffer areas are required to store depth values and intensity. One a depth buffer is used to
store depth values for each (x, y) positions. Second is refresh buffer stores the intensity values
for each position.
An extension of scan l ine polygon filling with multiple surfaces, it is to intersect each polygon with a
particular scan line solving hidden surface problem. Across each scan line depth calculations are made
for each over lapping surface to determine which is nearest to the view plane.
Scan lines are processed from left to right. For the various surfaces 2 tables are used to store the
data.
(i) Edge Table: contains co-ordinate points for each line in the screen.
(ii) Polygon table: contains co-efficient of the plane equation for each surface.
Questions:
Chapter 6
Segments
A segment is a set of output primitives that are joined for modification purpose.
Segments are the subdivision of pictures, segments are the visualization of a particular part of the
picture and we can apply translation scaling and rotation.
To create new segments we first open the segments and then call Graphics primitives to modify
the segments and then we must close the segment. To remove a segment from the display file.
Segment File
List of segments are maintained by a Graphics system is known as segment file. Segment file often
are stored as linked structures.
Starting Segment
Address
Segment Attributes
1. Visibility - Visibility of a segment can be set by the user with the function.
achieve segment transformations, the user can specify the transformation like size,
position and orientation matrix which needs to be applied to the individual segments.
Questions:
1. Give any two functions for segmenting.(1M,DEC2011)
2. Explain storage of segment files. (1M,DEC2011)
3. Explain the attributes of segments?
Chapter 7
The Co-Ordinate information of the object can be entered using input devices.
Once the information has entered in it can be modified to re-arrange (or) reshape the object. We
see several techniques available in Graphical packages to construct the interactive pictures using
input devices.
Positioning Techniques
Positioning involves the user in the first moving cursor (or) tracking cross to the desired spot on
the screen and then notifying the computer by pressing a button (or) key. A single positioning
operation can be used to insert a symbol as in the picture and two succession can be defined the
end points of a line.
The user indicates a position on the screen with an input device and this position is used to insert
a symbol. Positioning is also known as locating.
Constraints
There are many kinds of constraints functions that can be specified, but the most common
Grids
Any input co -ordinate position is rounded to the nearest intersection of 2 grid lines each of the 2
cursor position is shifted to the nearest grid position point and the line is drawn between these grid
points.
Gravity Field
When constructing a pictu re, we sometimes need to connect lines at position between endpoints.
Since exact positioning of the screen cursor at the connecting point can be difficult, graphics
packages can be designed to convert any input position near a line to a position on the li ne
Any selected position with the gravity field of a line is moved to the nearest position on the line.
Straight lines, Rectangles & circles can be constructed and positioned using RubberBandMethods.
We first select a screen position for one end point of the line, as the cursor moves around the line
Dynamic Manipulation
Options for sketching and drawing and painting comes in a variety of forms curved drawing can
be provided using standard curve shapes such as circular arcs with free hand sketching procedures.
In free hand drawing curves are generated by following the path of styles on graphic tablets (or)
the path of the screen cursor on a video monitor.
Pointing and selecting technique is used to select the picture parts that need modification.
Selection
When the user has positioned the curser over the object to select, we can press one of the
several keys according to the type of object. The selection can be one key to select a line,
another to select a point and a third one to select a symbol.
4. Prefix commands
The type of object to be selected can be determined by the user priori/previous choice of
command. The command is given before the selection and many specifies which type of object
is to be selected.
5. Modes
The user may be able to change the selection mechanism by setting different modes of
operation. In one mode the program allow only line selection and in another program allow
only the symbol selection.
Multiple Selections
(i) To indicate the first and last element in the line sequence to be
selected.
(ii) To select the element by specifying a bounding rectangle. (iii)
The user must select each one.
Menu Selection
Menu is displayed on the screen and the user points to the selection with a graphical input
device. Menus can be used for a variety of reasons.
Selection By Name
In this technique the user must type the name of the choice. If the user knows the names of
various objects, then referring to them by name would be reasonable and faster than pointing
method.
Selection by naming is also the best method for experienced and regular users. When the name
typed does not match one in the system, other name close to the typed name must be presented
to the user as alternatives.
Questions:
CHAPTER 8
Graphical Input Device
An input device is any peripheral device (piece of hardware) used to provide data and control
signals to an information processing system. All the computers have keyboard which is an input
device. The other input devices are Mouse, trackball, joystick, touchpad and Light pen.
Keyboard.
• It is an Input Device.
• It is design came from typewriter.
• A person can type document access menus, play games and perform variety of tasks.
The keys on computer keyboards are often classified as follows alphanumeric keys,
punctuation keys and special keys.
Types of Mouse:
1. Mechanical mouse 2.
Opto Mechanical 3.
Optical mouse.
Actions:
1. Pointing: Points to a particular object on the screen.
2. Single click: It selects the object.
3. Double click: It opens selected files.
4. Right click: Displays a popup menu corresponding to the selected object.
5. Drag and Drop: Dragging the one object to another location.
Advantages:
1. Easy to use
2. Low cost
3. No need to type commands
4. Easy to select menus and open them
Touch Pad
It is pointing devices consists of specialized surface and translate the motion and position of a
user‟s finger to relative position on screen.
Touchpad‟s are small sensitive tablets commonly used on laptop computers.
Most Touchpad supports support an absolute mode to allow Asian language to input or
signature.
Touchpad typically respond in relative mode because of the small size of the pad.
Features
1. They are commonly used for laptops.
2. Used as a substitute for a computer mouse.
3. Touch pads vary in size but are rarely made larger than 40 square centimetres.
A basic touch pad has 3 main components.
1. Touch sensor.
2. Controller.
3. Software driver.
Trackball
Joystick:
It is an input device consisting of a stick that pivots on a base and reports its angle or direction to
the device it is controlling.
A joystick consists of a small, vertical level mounted on a base that is used to steer the
screen cursor around.
Most joysticks select screen positions with actual stick movement.
Potentiometers mounted at the base of the joystick measure the amount of movement.
Questions: