Computer Graphics Unit1
Computer Graphics Unit1
Computer Graphics Unit1
Computer Graphics:
An ability of drawing pictures, lines, charts, etc by means of computers through programming is
defined as computer graphics. It converts data to and/or from visual arrangement using
computers. It uses a computer to create pictures. Algorithms, mathematics, data structures enable
a computer to make Pretty Pictures. Ivan Edward Sutherland is widely regarded as the "father of
computer graphics”
[2]. Computer Graphics has two main aspects namely technical and art. Computer Scientists
create libraries and tools etc for artists or non technical person, so that they can make use of it to
create pretty pictures. Artistic person uses these computer graphics tools to create attractive
pictures [1]. The technical definition of computer graphics includes composition of four
important steps:
2) Frame Buffer: A special area of memory is dedicated to graphics only, and picture
definition is stored in this memory area which is called frame buffer or refresh buffer.
This memory area holds the set of intensity values for all the screen points and the stored
intensity value are then retrieved from this frame buffer and painted on the screen one
row at a time to display picture.
3) Resolution: It refers to the maximum number of dots or points that can be displayed on
the screen without overlap on the Cathode Ray Tube (CRT). It is expressed as the number
of points per centimeter that can be plotted horizontally and vertically. Resolution
depends on the type of phosphor, the intensity to be displayed and the focusing and
deflection systems used in the CRT. The most commonly used four resolutions today are:
640 × 480, 1024 × 768, 800 × 600, 1280 × 1024.
4) Aspect Ratio: This number gives the ratio of vertical points to horizontal points
necessary to produce equal-length line in both directions on the screen. Sometimes it is
also referred to as the ratio of horizontal to vertical points. An aspect ratio of 5/6 means
that a vertical line plotted with 5 points has the same length as a horizontal line plotted
with 6 points. eg. aspect ratio of
12” × 16” display is 12/16 = 3/4.
5) Persistence: The operation of most video monitors is based on standard Cathode Ray
Tube (CRT). The screen of the video monitors is usually phosphor coated. Different
kinds of phosphors are available for use in a CRT. Besides color, a major difference
between phosphors is their persistence i.e. how long they continue to emit light after the
CRT beam is removed. Persistence is basically defined as the time it takes the emitted
light from the screen to decay to one-tenth of its original intensity. Lower persistence
phosphors required higher refresh rates to maintain a picture on the screen without
flicker. A phosphor with low persistence is useful for animation, a high –persistence
phosphor is used for displaying highly complex static pictures. Although, some
phosphors have persistence greater than 1 second, graphics monitors are usually
constructed with persistence in the range from 10 to 60 microseconds
Plotting Primitives of Computer Graphics
Lines and Line Segments: Point can be specified by giving pair of numbers (x, y), where
x represents horizontal distance and y represents vertical distance. Every line is described
by the equation such that if a point (x, y) satisfies the equation, then that point is on the
line. If the two points used to specify a line are (x1, y1) and (x2, y2) then the equation of
line will be,
Above equation justify that slope between any point on the line and point (x1, y1) is the
same as the slope between (x1, y1) and (x2, y2). Slope is usually denoted by m and is
defined as the change in height divided by the change in width for any two points on the
line. Slope m is defined in equation form as follows:
There is a difference between line and line segment. The lines can extend forever both
forward and backward direction but a line segment is a piece of line lying in between two
end points P1 and P2. If the end points are P1 = (x1, y1) and (x1, y1) = (x2, y2) and these
two points yield a equation y = mx +b then point P3 = (x3, y3) lies on the segment if y3 =
m x3 + b, x3 is in between x1 and x2 and y3 is in between y1 and y2. We can identify where
two lines are intersecting. Two lines are crossing or intersecting means they share
common point. That point satisfies the equation for both the lines. The intersection point
is given by below equation:
v Dy
Dx
We can multiply vector by a number and length of the vector can be given by
Pythagorean theorem.
If we multiply a vector by reciprocal of its length then the resultant vector is of length
equal to 1 and such a vector is called unit vector.
The process of “Turning ON” the pixels for a line segment is called a vector generation.
Whenever we need to draw a line, we need to turn ON the pixels on that line i.e. we need
to change the intensity of the pixels present on the line. Two well known algorithms used
for vector generation are Digital Differential Analyzers (DDA) and Bresenhans Line
Drawing Algorithm. Both the algorithms make use of increment method.
Line Drawing Algorithms
A basic element in graphics is that a line connects two points.. To draw a line, we need two
points between which we can draw a line. In line drawing algorithms, line is drawn between one
point of line as (x0, y0) and the second point of line as (x1, y1).
DDA algorithm is an incremental scan conversion method. Here we perform calculations at each
step using the results from the preceding step. The characteristic of the DDA algorithm is to take
unit steps along one coordinate and compute the corresponding values along the other
coordinate. The unit steps are always along the coordinate of greatest change, e.g. if dx = 10 and
dy = 5, then we would take unit steps along x and compute the steps along y [14]. Algorithm for
DDA line drawing is described stepwise as follows:
Algorithm [15]
Step 1: Accept the two end points (x0 , y0 ) and (x1 , y1 ) as an input.
Step 2: Calculate the horizontal and vertical difference between two end points.
dx = |x1 - x0|
dy = |y1 - y0|
Step 3: Based on the calculated difference in step 2, identify the number of steps to put pixel. If
dx > dy, then we need more steps in x coordinate; otherwise in y coordinate.
1. It is the simplest algorithm and it does not require special skills for implementation.
2. It is a faster method for calculating pixel positions than the direct use of equation y = mx + b.
It eliminates the multiplication in the equation by making use of raster characteristics, so that
appropriate increments are applied in the x or y direction to find the pixel positions along the line
path [14].
Disadvantages
Step 1: Read the line end points (x1, y1) and (x2, y2) such that they are not equal.
Step 4: Initialize the value of error or decision varaiable to compensate for non-zero
interrupts; e = 2 * dx - dy
Step 5:Initialize counter; i = 0
Step 6: Plot(x, y)
REFERENCES:
1) http://www.webopedia.com/TERM/G/Graphical_User_Interface_GUI.html
2) https://www.wikipedia.org/
3) http://www.computerhope.com/
4) http://study.com/academy/lesson/what-is-a-graphical-user-interface-gui-definition-
components-examples.html
5) http://whatis.techtarget.com/definition/CAD-computer-aided-design
6) http://www.webopedia.com/TERM/C/CAD.html
7) http://brasil.cel.agh.edu.pl/~12sustrojny/en/przykladowe-zastosowania-nowoczesnej-
grafiki-komputerowej/przemysl-rozrywkowy/
8) https://en.wikipedia.org/wiki/Visualization_(graphics)
9) http://www.slideshare.net/aainakatyal/applications-of-computer-graphics
10) http://www.slideshare.net/VishnuRam7/computer-graphics-12567217
11) https://www.tutorialspoint.com/computer_graphics/computer_graphics_basics.htm
12) https://www.cise.ufl.edu/~sitharam/COURSES/CG/kreveldintrolinesegment.pdf
13) http://ecomputernotes.com/computer-graphics/simple-line-drawing-method/write-
short-note-on-digital-differential-analyzer-dda
14) https://www.tutorialspoint.com/computer_graphics/pdf/line_generation_algorithm.pdf
15) https://sites.google.com/site/assignmentssolved/mca/semester3/mc0072/2
16) http://www.eazynotes.com/notes/computer-graphics/programs/program-to-draw-a-line-
using-dda-algorithm.pdf
17) http://mcasjcet.weebly.com/uploads/4/4/7/9/4479347/computer_graphics_first_module_seco
nd. pdf
18) http://graphics.idav.ucdavis.edu/education/GraphicsNotes/Bresenhams-Algorithm.pdf
19) http://www.dailyfreecode.com/code/bresenham-line-drawing-algorithm-694.aspx