0% found this document useful (0 votes)
146 views72 pages

CG

The document provides an introduction to computer graphics including its history, applications, and classifications. It discusses the evolution of computer graphics from the 1950s to the 1990s and applications such as CAD, presentation graphics, computer art, entertainment, education and training, information visualization, image processing, and virtual reality. It also describes different types of computer graphics based on object dimensionality, interaction level, relationship between objects and pictures, and graphics software categories. The document concludes with explanations of interactive graphics displays, CRT monitors, raster scan displays, and advantages and disadvantages of each.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
146 views72 pages

CG

The document provides an introduction to computer graphics including its history, applications, and classifications. It discusses the evolution of computer graphics from the 1950s to the 1990s and applications such as CAD, presentation graphics, computer art, entertainment, education and training, information visualization, image processing, and virtual reality. It also describes different types of computer graphics based on object dimensionality, interaction level, relationship between objects and pictures, and graphics software categories. The document concludes with explanations of interactive graphics displays, CRT monitors, raster scan displays, and advantages and disadvantages of each.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 72

VIDYAVAHINIFIRSTGRADECOLLEGE

COMPUTER GRAPHICS
6th Sem BCA

Vidyavahini First Grade College


Near Puttanjaneya Temple, Kuvempunagar, Tumkur – 572103.

E-Mail:[email protected]
Website:www.vidyavahini.org/bca

Contact No: 0816 – 2261130

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.

History of Computer Graphics:


• 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

• In the early 1970‟s output started using raster displays.

• In the 1980‟s output are built in raster graphics, bitma


p image and pixel. Pc costs decrease

• 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 helpsnematic
in ci Graphics applications.

Applications of Computer Graphics:


1. Computer Aided Design
(CAD).
2. Presentation Graphics.
problem was cost and inaccessibility of machines. drastically.

3. Computer art
4. Entertainment
5. Educational and Training
6. Information visualization
7. Image processing

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.

Ex: flight simulation, automobile driving simulators…

Information Visualization: visual representation and interaction techniques take advantage


of the human eyes broadband width pathway in to mind to allow users to see, explore and
understand large amount of information at once. Computer Graphics is increasingly applied as
a critical component in scientific research, digital libraries, data mining, financial data analysis
etc.

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.

Computer Graphics Classifications:


A computer Graphics can be categorized in to different variety of ways.
a) Types of objects (Dimensionality): the objects can be represented graphically two
dimensional or three dimensional type.

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

a) General Graphics Programming Packages:it is used in high level programming


language. It uses a set of graphics functions to generate picture components like
straight lines, polygons, circles, rectangles etc. ex: c and Fortran.

b) Application Graphics Packages: it is designed for non programmers so that users can
generate and display without knowing how graphics operation works. Some
software‟s are photoshop, coraldraw, Microsoft paint, picasa etc.

Interactive Graphics Display:


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 maintain
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.

Cathode Ray Tube [CRT]:


A cathode ray tube is a vacuum tube in which images are produced when an electron beam strikes
a phosphor coated surface.
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

Factors affecting CRT:


1. Resolution: the number of pixels or points per inch or centimeters, if the pixels are
more than the clarity and sharpness of the picture is high. The pixels size is smaller
than the resolution is higher. The higher quality resolution is 1280*1024.

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.

3. Addressability: it is a measure of the spacing between the centers of vertical and


horizontal lines. The smallest addressable point on the screen is called pixel or
picture element.

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)

Raster scan Display(Monitor)


Advantages:
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.
(i) Images can be displayed with realistic and includes 3D effects also.
(ii) The cost is very low compared to other devices.

(iii) Computers monitors and TV‟s use this method.


Disadvantages:
(i) Resolution is low.
(ii) The lines produced are zigzag
(iii) High speed display application and animations cannot use this technique.
(i) High resolution.
(ii) Producing smooth line drawing.
(iii) Easy for animation.

Disadvantages:
(i) Costlier (or) over cost.
(ii) Difficult to display realistic images.
(iii) This technique cannot be used to draw complex images.
i) Beam – Penetration method. ii)
Shadow – mask method.

Beam – Penetration method:


Shadow-Maskmethod: it is commonly used in Raster Scan system like color T.V.
Computer Graphics Vidyavahini First Grade college, Tumkur

There are 2 types of display processor.

(i) Raster-Scan display processor.


(ii) Random-Scan Display Processor.

Department of BCA Page 12


Computer Graphics Vidyavahini First Grade college, Tumkur

Raster-Scan Display Processor:Interactive Raster Graphic Systems typically has several


processing units. In addition to the CPU a video controller is used to control the operation of the
display devices.

Department of BCA Page 13


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

Department of BCA Page 14


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

The different type of color models are

(i) RGB color model [Red, Green, Blue]


(ii) CMY color model [cyan, magenta, yellow].
(iii) YIQ [using RGB, removing the luminance in RGB and contact with ultraviolet (UV) and
producing different colours].

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)

Department of BCA Page 15


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

X2– X1

Department of BCA Page 16


Computer Graphics Vidyavahini First Grade college, Tumkur

b = Y1– mx1
The „Y‟ intercept „b‟ is

dy else
steps = dx

x1nc = dx | Steps
y1nc = dy | Steps

Department of BCA Page 17


Computer Graphics Vidyavahini First Grade college, Tumkur

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,

Put pixel (x, y, RED);


}
|| End of function.

Department of BCA Page 18


Computer Graphics Vidyavahini First Grade college, Tumkur

Bresenhams Lien Algorithm


An accurate and efficient line generating algorithm developed by Bresenhams, Scan converts lines using
only incremental integer calculations 0<|M|<_1

Bresenhams algorithm is designed such that each interaction changes one of the coordinate values by +
1 (or) – 1.

Defining the decision parameter as Po = 2dy – dx


The next value is evaluated depending on whether Po is Positive (or) Negative. If Po <O
the next point to plot is (Xk+1,Yk) otherwise plot (Xk+1,Yk+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 6: stop

Department of BCA Page 19


Computer Graphics Vidyavahini First Grade college, Tumkur

Difference between DDA Line algorithm and Brensenhams line algorithm.

DDA Line Algorithm Bresenhams Line Algorithm

• X inc and Y inc are calculated The increment value of X and Y is always based on the formula.
Unity.

• There is no decision parameter used There is a decision parameter used.


• Both x and y values are incremented Depending on the decision parameter the at every step.
X and Y values are incremented.

Circle Generations

DDA Circle Generation Algorithm

The differential equation of a circle with centre at Origin is dy/dx=-x/y

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-y c ) 2 =r 2
The distance relationship is written as

The circular boundary using polar co-ordinates „r‟ and θ


Xnew=xc+rcos θ

Department of BCA Page 20


Computer Graphics Vidyavahini First Grade college, Tumkur

Bresenham’s Circle Generating Algorithm.

Department of BCA Page 21


Computer Graphics Vidyavahini First Grade college, Tumkur

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);}

Department of BCA Page 22


Computer Graphics Vidyavahini First Grade college, Tumkur

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:

Where((x c.y c )=(0,0) Region


iii)

Color (i)
Line
Type :

Department of BCA Page 23


Computer Graphics Vidyavahini First Grade college, Tumkur

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) Line Width:


Set the line width attribute with the command “setLinewidthScaleFactor (lw)”
Where lw = is a positive no. indicating the relative width of a line.
The value „1‟ specifies a standard width line and value>1 produce line thicker. We can adjust the shape
of the line ends to given than a better appearance by adding line caps. There

Department of BCA Page 24


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

• For each scanline locate the intersection of the scanline with the edges.

• The intersection points are then stored from left to right.

• Generate frame buffer positions along the current scanline between each pair of intersections are
set to the specified fill color.

• When a scanline passes through a vertex, it intersects 2 polygon edges at that point and fills the
color.

Area filling attributes:


Fill an area with a solid color (or) a patterned fill and choices for the particular color and pattern.
(ii) Starting from a point inside the area and painting outwards until the boundary definition is
encounter.

Scanline algorithm for “area fill”


Scanline filling algorithm is used for filling polygon areas. This procedure contains the following
steps.

Department of BCA Page 25


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

The basic fill style command is,


setInterior Style (fs);
Where fs (fill style) include hallow, solid and pattern.
Another value for fill style is “Hatch”, which is used to fill an area will be selected hatching pattern parallel
lines (or) crossed lines.

Department of BCA Page 26


Computer Graphics Vidyavahini First Grade college, Tumkur

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

Department of BCA Page 27


Computer Graphics Vidyavahini First Grade college, Tumkur

1. Explain attributes of line.(5M,DEC 2011)


2. Explain DDA line algorithm with an example.(5M,DEC 2011)
3. Explain scan-line algorithm for area filling.(5M,DEC 2011)
4. Write the Bresenham,s line drawing algorithm.(5M,DEC 2011)
5. What is an output primitive
6. What is point in computer graphics?
7. What is character up vector?
8. Explian the character attributes?
9. Explain area fill attributes?
10. Explain midpoint circle algorithm?

Department of BCA Page 28


Computer Graphics Vidyavahini First Grade college, Tumkur

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.”
2D TRANSFORMATION
Chapter 3 The basic Geometric
transformations are

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 coordinate
position (x, y), after moved the object the new positions are (Xnew, Ynew).

Department of BCA Page 29


Computer Graphics Vidyavahini First Grade college, Tumkur

The translation distance pair T(tx, ty) is called the translation vector (or) shift vector.

Department of BCA Page 30


Computer Graphics Vidyavahini First Grade college, Tumkur

(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

Department of BCA Page 31


Computer Graphics Vidyavahini First Grade college, Tumkur

+ 𝜽)
Xnew= rcos 𝜱cos 𝜽-rsin 𝜱 sin 𝜽 Ynew=

rcos 𝜱sin 𝜽-rsin 𝜱cos 𝜽 Rotations are

rigid body transformations that move

object without deformation. Every point on

an object gets rotated through the same

angle.

The matrix representation using 3*3 matrix

Department of BCA Page 32


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

Department of BCA Page 33


Computer Graphics Vidyavahini First Grade college, Tumkur

Xnew=X+ Shx.Y

Ynew = Y

Department of BCA Page 34


Computer Graphics Vidyavahini First Grade college, Tumkur

Department of BCA Page 35


Computer Graphics Vidyavahini First Grade college, Tumkur

(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.

Department of BCA Page 36


Computer Graphics Vidyavahini First Grade college, Tumkur

The general form is

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

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)

Department of BCA Page 37


Computer Graphics Vidyavahini First Grade college, Tumkur

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?

Department of BCA Page 38


Computer Graphics Vidyavahini First Grade college, Tumkur

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 specified in the world co-ordinates is called a Window”.

“A rectangular area of the display device, which will contain the picture to which a window is
mapped, is called a view port.”

Steps involved in 2 – Dimensional viewing transformation.

Department of BCA Page 39


Computer Graphics Vidyavahini First Grade college, Tumkur

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

1. Extracting parts of a specified region for viewing.


2. Locating visible surfaces in 3 – D views.
3. Anti – aliasing line segments of objects.
4. Creating objects using solid modelling procedures.

Department of BCA Page 40


Computer Graphics Vidyavahini First Grade college, Tumkur

The method of line clipping involves several parts

(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.

Cohen – Sutherland Line Clipping Algorithm

Department of BCA Page 41


Computer Graphics Vidyavahini First Grade college, Tumkur

This algorithm is invented by Dan Cohen and Ivan Sutherland, is very good for clipping picture that are
much larger than the screen.

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.

Department of BCA Page 42


Computer Graphics Vidyavahini First Grade college, Tumkur

The bounding rectangle for the curved object is first tested for ovelap (or) intersection
then the object is saved otherwise discarded.

Department of BCA Page 43


Computer Graphics Vidyavahini First Grade college, Tumkur

Blanking (or) Exterior Clipping


If we want to clip a picture to the exterior specified region, i.e., all the parts outside the region

5. Area Clipping (or) Polygon 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.

A technique for clipping polygons developed by Sutherland and Hodgeman.

Sutherland – Hodgeman Polygon Clipping Algorithm.

The Sutherland – Hodgeman algorithm is based on the fact it is easy to click a polygon against a single
must be retained but within the window boundary region is discarded is known as blanking (or)

exterior clipping. 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.

Department of BCA Page 44


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

Department of BCA Page 45


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

Midpoint Sub-Division Algorithm

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 1: Lines are completely inside the visible 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:

1. Differentiate between Window and Viewport.(1M,DEC 2011)


2. Explain exterior clipping. (1M,DEC 2011)
3. How is curve clipping performed? (1M,DEC 2011)
4. Explain Cohen Sutherland curve clipping algorithm(1M,DEC 2011)
5. Explain different forms of text clipping.(5M,DEC 2011)
6. Describe the cohen Sutherland algorithm for line clipping.
7. Explain the midpoint subdivision method of clipping a line segment.

Department of BCA Page 46


Computer Graphics Vidyavahini First Grade college, Tumkur

8. What are the different types of text clipping explain with example.
9. How is curve clipping performrd?
10. Distinguish between windows and viewport?

Chapter 5 Three
Dimensional Displays

Department of BCA Page 47


Computer Graphics Vidyavahini First Grade college, Tumkur

Three Dimensional Display Techniques

It is representation of a solid object on a viewing surface usually contain depth information.

Department of BCA Page 48


Computer Graphics Vidyavahini First Grade college, Tumkur

Parallel projection involves generating a view of a solid object by projecting points on the object
surface along parallel lines onto the display plane.

Department of BCA Page 49


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

Department of BCA Page 50


Computer Graphics Vidyavahini First Grade college, Tumkur

Difference between Parallel And Perspective Projection.

Parallel projection Perspective Projection

1.The Projection are parallel 1. The projection intersect at the to each


other. thecentre of position.
2. Less realistic in parallel 2. Visual effect is similar to Projection.
3.Preserves the parallel lines. 3. Do not preserve the parallel Lines.
4.The centre of projection is at 4. The centre of project is a
Infinity. Finite point.
Intensity Cueing (or) Depth Cueing
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.

Hidden Line Removal


This technique is useful when objects are defined as a set of lines representing the edges of the
surface of the objects. Any lines that are hidden by front surface are removed before the object is
displayed.

Department of BCA Page 51


Computer Graphics Vidyavahini First Grade college, Tumkur

Department of BCA Page 52


Computer Graphics Vidyavahini First Grade college, Tumkur

Department of BCA Page 53


Computer Graphics Vidyavahini First Grade college, Tumkur

plane. By specifying the angle of rotation which the object is to be rotated.

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.

Department of BCA Page 54


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

Polygon tables can be divided into 2 groups.

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

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.

Department of BCA Page 55


Computer Graphics Vidyavahini First Grade college, Tumkur

(ii) Intersection: A block and a cylinder with overlapping volumes, using the intersection operation,

points to the next node in the oct tree.

Oct trees can be generated by using the procedure of quad trees.

Department of BCA Page 56


Computer Graphics Vidyavahini First Grade college, Tumkur

Fractal Geometry Method


There are no. of objects like mountains and clouds which have irregular (or) fragmented
features, such objects cannot be represented as smooth surface, they can be modelled using the
fractal Geometry method, that was developed by Mandelbrot.

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.

A pplications 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.

1. Self – Similar [Trees, Pla nts, Shrubs].


2. Self – affine [water, clouds, etc]
3. Invariant Fractals [self squaring fractals and self inverse fractals]

Bezier Curves

P Bezier pioneered the use of computer modelling of surfaces in automobile design. His method has been
applied to defin e 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)

Where blending function,

Where the binomial co-efficient.

Department of BCA Page 57


Computer Graphics Vidyavahini First Grade college, Tumkur

According to x, y, z plane the respective Bezier curves are,

– 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.

Department of BCA Page 58


Computer Graphics Vidyavahini First Grade college, Tumkur

If C < O the polygon is a back – face since the normal vector points away from the viewing position.

Depth Buffer Method


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.

Department of BCA Page 59


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

Scan Line Method

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.

Department of BCA Page 60


Computer Graphics Vidyavahini First Grade college, Tumkur

Questions:
1. .Explain intensity cueing.(1M,DEC 2011)
2. Explain perspective projection technique.(1M,DEC 2011)
3. What is a cubic Bezier curve? What is the order of the polynomial for a cubic Bezier curve?
(5M,DEC 2011)
4. lustrate polygon tables with an example.(5M,DEC 2011)
5. Explain Depth-Buffer algorithm.(5M,DEC 2011)
6. Explain scan-line method for multiple surfaces.(5M,DEC 2011)
7. Explain union, intersection and differencesolid-geometry methods.(3M,DEC 2011) 8. Write
a short note on Graphical input techniques and octrees.(3M,DEC 2011)
9. What is Fractal? Explian.
10. Explain parallel and perspective projection?

Department of BCA Page 61


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

Functions for segmenting the display file.

Segment Attributes

1. Visibility - Visibility of a segment can be set by the user with the function.

Department of BCA Page 62


Computer Graphics Vidyavahini First Grade college, Tumkur

Set _visibility (id, v) where id- segment no.


V-visible (or) invisible.
2. Priority- segments priority can be set with the function.

Set _Segment Priority (id,p) where p- priority

3. Highlights – highlighting of a segment is implemented with the function. Set_highlight(id,


h) where h-highlight or normal 4. Transformation- transformation is implemented with
the function.

Set_segment_transformation (id, matrix) where matrix specifies the


element of the transformation matrix. To

Questions:
1. Give any two functions for segmenting.(1M,DEC2011)
2. Explain storage of segment files. (1M,DEC2011)
3. Explain the attributes of segments?

achieve segment transformations, the user can specify the transformation like size, position
and orientation matrix which needs to be applied to the individual segments.

Department of BCA Page 63


Computer Graphics Vidyavahini First Grade college, Tumkur

Chapter 7 Graphical Input Techniques


Interactive Picture Construction Techniques

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.

Department of BCA Page 64


Computer Graphics Vidyavahini First Grade college, Tumkur

Constraints

There are many kinds of constraints functions that can be specified, but the most common

Any selected position with the gravity field of a line is moved to the nearest position on the line.

Department of BCA Page 65


Computer Graphics Vidyavahini First Grade college, Tumkur

Rubber – Band Method

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
stretches out from the starting position to the current position of the cursor. When we finally select
second position then it constructs line.

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 & Selections

Department of BCA Page 66


Computer Graphics Vidyavahini First Grade college, Tumkur

Pointing and selecting technique is used to select the picture parts that need modification.

Selection
Selection is a useful tool in the hands of the user for selecting the images.

Different types of selection techniques are

1. Use of selection points.


2. Defining a bounding rectangle.
3. Multiple keys for selections.
4. Prefix commands.
5. Modes.
1. Use of selection points.
In order to select a Graphical unit the user points to a specific spot such as the centre of a
circle (or) an endpoint of a line selection points can be provided for symbols and larger sub
pictures.

2. Defining a bounding rectangle.


The user can define two opposite corners of a rectangle and in this way select an object that
lines within the rectangle. This techniques is useful for multiple selection.

3. Multiple keys for selections.

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.

For Eg:- There are 3 different DELETE commands are available.

i.e., DELETTE POINT, DELETE LINE, DELETE SYMBOL

5. Modes

Department of BCA Page 67


Computer Graphics Vidyavahini First Grade college, Tumkur

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
The user must be able to select more than one element at a time. Multiple selection can be provided
in a no. of ways.

(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.

1. They allow the user to choose an element for insertion.


2. To change the mode of operation of the program.
3. To issue a command.
4. They protect the user from making an invalid selection.

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:

1. Explain pointing and selection techniques.(1M,DEC 2011)


2. Explain menu in detail?
3. Explain constraints?
4. Explain the selection Techniques?
5. Explain Rubber band method?

Department of BCA Page 68


Computer Graphics Vidyavahini First Grade college, Tumkur

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.

Two types of Graphical interaction

1. Pointing Device- points item already on the screen


2. Positioning Device- positioning new items.

Keyboard.

In a computer a “keyboard” is a device that converts letters, numbers and other


character into electronical signals that are machine readable by the computer‟s process. The
keyboard may look like a typewriter keyboard to which some special keys have been added.

• 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.

Mouse [Mechanically Operated Use Serial Engineer]

Types of Mouse:

1. Mechanical mouse 2. Opto


Mechanical 3.
Optical mouse.

Department of BCA Page 69


Computer Graphics Vidyavahini First Grade college, Tumkur

Main Goals of Mouse


It is to translate the motion of the hand into signals that the computer can understand and
use.

Department of BCA Page 70


Computer Graphics Vidyavahini First Grade college, Tumkur

A mouse is small hand-held box used to position the screen cursor.


The mechanical mouse uses a rubber coated ball on the underside. The movement of this ball
will sends electrical signals to the system.
The optical mouse uses diodes to emit light on to a metal pad.

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.

Department of BCA Page 71


Computer Graphics Vidyavahini First Grade college, Tumkur

Trackball
It is a computer cursor control device that can be rotated with the fingers (or) palm of the
hand.
It was invented by Tom Cranston and Fred Long staff as part of the Royal Canadian
Navy‟s DATAR system in 1952.
Compared with a mouse, a trackball has no limits on effective travel; a mouse can reach an edge
of its working area.
A Trackball is a ball that can be rotated with the fingers to produce screen cursor
movement. Potentiometers attached to the ball measure the amount and directions of rotation.
Trackball are used for three dimensional positioning and selection operations in virtual systems.

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.

Department of BCA Page 72

You might also like