Computer Graphics Overview and Applications
Computer Graphics Overview and Applications
Unit I
1.1) Introduction:
“Creation, Manipulation and Storage of geometric objects and their images & displaying
those images on screen or hardcopy devices are called computer graphics.”
Or
“Computer graphics are graphics created using computers and the representation of
image data by a computer by using specialized graphic hardware and software.”
A computer graphic development is important for animation, movies and the video
game industry.
Typically, the term computer graphics refers to several different things:
i. The representation and manipulation of image data by a computer ii.
The various technologies used to create and manipulate images
iii. The sub-field of computer science which studies methods for digitally
synthesizing and manipulating visual content
Many powerful tools have been developed to visualize data. Computer generated
imagery can be categorized into several different types: two dimensional (2D), three
dimensional (3D), and animated graphics.
As technology has improved, 3D computer graphics have become more common, but 2D
computer graphics are still widely used.
Computer Graphics is any computer device or program that makes a computer capable of
displaying and manipulating pictures.
A graphics card is a printed circuit board that, when installed in a computer, permits the
computer to display pictures.
Many software applications include graphics components; Such programs are said to
support graphics.
For example, certain word processors support graphics because they let you draw or
import pictures.
All CAD/CAM systems support graphics. Some database management systems and
spreadsheet programs support graphics because they let you display data in the form of
graphs and charts.
systems and processing parameters are shown on the computer with graphic symbols and
identifications. This makes it easy for operator to monitor and control various processing
parameters at a time.
1. It provides tools for producing pictures not only of concrete real world
objects but also of abstract, synthetic objects such as mathematical surface in 4D
and of data that have no inherent geometry such as survey results.
3. With computer graphics user can also control the animation speed, portion
of the view, the geometric relationship the object in the scene to one another, the
amount of detail shown and on.
4. The computer graphics provides tool called motion dynamics, with this tool
user can move and tumble objects with respect to a stationary observer, or he can
make objects stationary and the viewer moving around them.
A typical example is walk through made by builder show flat interior and building
surroundings. In many case it is also possible to move both objects and viewer.
5. The computer graphics also provides facility called update dynamics. With update
dynamics it is possible to change this shape, color or other properties of the objects
being viewed.
6. With the recent development of digital signal processing (DSP) and audio
synthesis chip the interactive graphics can now provide audio feedback along with the
graphical feedbacks to make the simulated environment even more realistic.
In today’s times, graphical user interfaces are used in many devices such as
mobiles, MP3 players, gaming devices, smartphones etc.
The below diagram provides the position of the graphical user interface with
respect to the computer system :
The below diagram provides the position of the graphical user interface with
respect to the computer system
Window
This is the element that displays the information on the screen. It is very easy to
manipulate a window. It can be opened or closed with the click of an icon. Moreover, it
can be moved to any area by dragging it [Link] a multitasking environment, multiple
windows can be open at the same time, all of them performing different tasks.
There are multiple types of windows in a graphical user interface, such as container
window, browser window, text terminal window, child window, message window etc.
Menu
A menu contains a list a choices and it allows users to select one from them. A menu bar
is displayed horizontally across the screen such as pull down menu. When any option is
clicked in this menu, then the pull down menu appears.
Another type of menu is the context menu that appears only when the user performs a
specific action. An example of this is pressing the right mouse button. When this is done,
a menu will appear under the cursor.
Icons
Files, programs, web pages etc. can be represented using a small picture in a graphical
user interface. This picture is known as an icon. Using an icon is a fast way to open
documents, run programs etc. because clicking on them yields instant access.
Controls
Information in an application can be directly read or influences using the graphical
control elements. These are also known as widgets. Normally, widgets are used to
display lists of similar items, navigate the system using links, tabs etc. and manipulating
data using check boxes, radio boxes etc.
Tabs
A tab is associated with a view pane. It usually contains a text label or a graphical icon.
Tabs are sometimes related to widgets and multiple tabs allow users to switch between
different widgets. Tabs are used in various web browsers such as Internet Explorer,
Firefox, Opera, Safari etc. Multiple web pages can be opened in a web browser and users
can switch between them using tabs.
Random-scan displays are designed to draw all the component lines of a picture 30
to 60 times each second.
An image is subdivided into a sequence of (usually) strips known as “scan lines” which
can be further divide into discrete pixels for processing in a computer system.
As the electron beam moves across each row, the beam intensity is turned on and off to
create a pattern of illuminated spots.
The return to the left of the screen, after refreshing each scan line is called horizontal
retrace.
At the end of each frame the electron beam returns to the left corner of the screen to
begin the next frame is called vertical retrace.
Picture definition is stored in memory area called the Refresh Buffer or Frame Buffer.
Refresh buffer or frame buffer is memory area holds the set of intensity values for all the
screen points.
Stored intensity values are then retrieved from the refresh buffer and “painted” on the
screen one row (scan line) at a time as shown in the following illustration.
Each screen point is referred to as a pixel (picture element). At the end of each scan
line, the electron beam returns to the left side of the screen to begin displaying the next
scan line.
Home television computer printers create their images basically by raster scanning.
Common raster image formats include BMP (windows bitmap), JPEG (Joint
Photographic Expert Group), GIF (Graphics Interchange format), PNG (Portable
Network Graphic), PSD (Adobe Photoshop).
Disadvantages of raster scan display is to increase size of a raster image the pixels
defining the image are be increased in either number or size spreading the pixels over a
larger area causes the image to lose detail and clarity.
Common applications for electronic visual displays are televisions or computer monitors.
There are various designs for display devices, using various technologies.
The display controller simply reads each successive byte of data from the frame buffer
and converts each 0 and 1 to the corresponding video signal. This signal is then fed to
the monitor. If we wish to change the displayed picture all we need to do is to change of
modify the frame buffer contents to represent the new pattern of pixels.
Some of the display devices are: CRT, LCD, LED, Printer, Plotter, Projector etc..
Most monitors use cathode ray tubes ( CRT), which are glass vacuum tubes into which
an electron gun emits a flow of electrons guided by an electrical field towards a screen
covered in small phosphorescent elements.
The electron gun is made up of a cathode,(a negatively charged metallic electrode)
and one or more anodes (positively charged electrodes). The cathode emits the
electrons attracted by the anode.
The anode acts as an accelerator and concentrator for the electrons, forming a flow of
electrons aimed at the screen.
A magnetic field guides the electrons from left to right and from top to bottom. It is
created with two electrified X and Y plates (called deflectors) which send the flow
horizontally and vertically, respectively.
The fig below shows the electrostatic deflection of the electron beam in a CRT.
The deflection system of the cathode-ray-tube consists of two pairs of parallel plates,
referred to as the vertical and horizontal deflection plates. The voltage applied to vertical
plates controls the vertical deflection (bend) of the electron beam and voltage applied to
the horizontal deflection plates controls the horizontal deflection of the electron beam.
The screen is covered with a fine layer of phosphorescent elements, called phosphors,
which emit light by excitation when electrons strike them, creating a lit-up dot called a
pixel.
i. The definition: The number of pixels that the screen can display. This number is
generally between 640x480 (640 pixels long, 480 pixels wide), but higher
resolutions are technically possible.
ii. The size: This is calculated by measuring the diagonal of the screen, and is
expressed in inches . in general screens which are larger in size have a higher
definition.
iii. The dot pitch: This represents the distance which separates two phosphors of the
same color. The lower the dot pitch, the better the image quality.
iv. The resolution: This determines the number of pixels per surface unit. This is
abbreviated DPI( Dots Per Inch). A resolution of 300 dpi means 300 columns and
300 rows of pixels per square inch.
v. The refresh rate: This represents the number of images which are displayed per
second, or more precisely the number of times the image is refreshed each second.
Also called the vertical scan rate, it is expressed in Hertz.
2. Highest Resolutions
CRTs run at the highest pixel resolutions generally available.
5. Motion Artifacts
CRTs have fast response times and no motion artifacts. Best for rapidly moving or
changing images.
6. Cost
CRTs are less expensive than comparable displays using other display technologies.
2. Interference
All color CRTs produce annoying Moiré patterns. Many monitors include Moiré
reduction, which normally doesn't eliminate the Moiré interference patterns entirely.
3. Brightness
Relatively bright but not as bright as LCDs. Not suitable for very brightly lit
environments.
4. Screen Shape
Some CRTs have a rounded spherical or cylindrical shape screen. Newer CRTs are flat.
5. Emissions
CRTs give off electric, magnetic and electromagnetic fields. There is considerable
controversy as to whether any of these pose a health hazard, particularly magnetic fields.
The most authoritative scientific studies conclude that they are not harmful but some
people remain unconvinced.
6. Physical
They are large, heavy, and bulky. They consume a lot of electricity and produce a lot of
heat.
The basic principle behind colored displays is that combining the 3 basic colors –Red,
Blue and Green, can produce every color.
By choosing different ratios of these three colors we can produce different colors –
millions of them in-fact.
We also have basic phosphors, which can produce these basic colors. So, one should
have a technology to combine them in different combinations.
There are two techniques for producing color displays with a CRT are:
Advantages
i. Less expensive
Disadvantages
i. Quality of images are not good as compare with other methods
ii. Four colors are allowed only iii.
This type of CRT has three electron guns and a shadow mask grid as shown in following
figure:
In above figure, three electron beams are deflected and focused as a group onto the
shadow mask which contains a series of holes.
When three beams pass through a hole in shadow mask they activate dot triangle. The
colors we can see depends on the amount of excitation of red, green and blue
phosphor. A white area is a result of all three dots with equal intensity while yellow is
produced with green and red dots and so on.
Advantages
i. produce realistic images ii.
also produced different colors
iii. shadows scenes.
Disadvantages
i. low resolution ii.
expensive
iii. electron beam directed to whole screen
Conceptually the Direct View Storage Tube (DVST) behaves like a CRT with highly
persistent (determined) phosphor.
It is similar to CRT as far as the electronic gun and phosphor-coated mechanisms are
concerned.
But instead of the electron beam directly writing the pictures on the phosphor coated
CRT screen, the writing is done with the help of a fine-mesh wire grid.
A DVST monitor has both disadvantages and advantages compared to the refresh CRT.
Because no refreshing is needed, very complex pictures can be displayed at very high
resolutions without flicker.
Disadvantages of DVST systems are that they ordinarily (generally) do not display color
and that selected parts of a picture cannot be erased.
To eliminate a picture section (or part of picture), the entire screen must be erased and
the modified picture redrawn.
The erasing and redrawing process can take several, seconds for a complex picture.
The displaced electrons are attracted towards the collector. A flood gun is used for
picture display. Now, the continuous flowing slow speed electrons from flood electron
gun are attracted to the positively charged regions of the storage grid.
They penetrate the storage grid and hit the phosphor coating in CRT generating the
output. Here, the collector is used to control the flow of flood electrons.
1.7) Plotter:
A device that draws pictures on paper based on commands from a computer.
Plotters differ from printers in that they draw lines using a pen.
As a result, they can produce continuous lines, whereas printers can only simulate
(put on) lines by printing a closely spaced series of dots.
In general, plotters are considerably more expensive than printers. They are used in
engineering applications where precision is mandatory.
Unlike a regular printer, the plotter can draw continuous point-to-point lines directly
from vector graphics files or commands.
i) Drum Plotters
In this plotter the pen moves in the horizontally and the drum rolls on the other axis.
Generally it is a graphical output device, and it is generally used to plot drawings.
The width of the plot is limited by the length of the drum. It is the first graphical output
device produced to print large scaled engineering drawings.
Colored prints can be made if you use colored ink. This electronic equipment used to plot
large sized drawings on a tracing sheet. Plans for building (architectural drawing),
engineering drawings , dress models ETC are drawn using suitable packages. These
drawings are plotted on a tracing sheet, which can be used to produce a large no of blue
prints.
It is very good for line drawings but it is very slow. Here the pen is held in gantry and it
moves in x-axis and the paper moves on y-axis. ii) Flatbed Plotters
This is a plotter where the paper is fixed on a flat surface and pens are moved to draw the
image. This plotter can use several different colour pens to draw with. The size of the
plot is limited only by the size of the plotter's bed.
1.8) Joystick:
A joystick is similar to a mouse, except that with a mouse the cursor stops moving
as soon as you stop moving the mouse. With a joystick, the pointer continues
moving in the direction the joystick is pointing.
To stop the pointer, you must return the joystick to its upright position. Most
joysticks include two buttons called triggers.
Joysticks are used mostly for computer games, but they are also used occasionally
for CAD/CAM systems and other applications.
An input device that looks similar to a control device you would find on an arcade
game at your local arcades.
A joystick 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, also known as the control column, is the principal control device in the
cockpit of many civilian and military aircraft, either as a center stick or side-stick. It
often has supplementary switches to control various aspects of the aircraft's flight.
Joysticks are often used to control video games, and usually have one or more
pushbuttons whose state can also be read by the computer.
A popular variation of the joystick used on modern video game consoles is the analog
stick.
Joysticks are also used for controlling machines such as cranes, trucks, underwater
unmanned vehicles, wheelchairs, surveillance cameras, and zero turning radius lawn
mowers.
Miniature finger-operated joysticks have been adopted as input devices for smaller
electronic equipment such as mobile phones.
❖ Light pen:
A light pen is a computer input device in the form of a light-sensitive wand (pointer or
rod) used in conjunction with a computer's CRT TV set or monitor.
It allows the user to point to displayed objects, or draw on the screen, in a similar way to
a touch screen but with greater positional accuracy.
A light pen can work with any CRT-based display, but not with LCD screens projectors
and other display devices.
A light pen detects a change of brightness of nearby screen pixels when scanned by
cathode ray tube electron beam and communicates the timing of this event to the
computer.
Since a CRT scans the entire screen one pixel at a time, the computer can keep track of
the expected time of scanning various locations on screen by the beam and conclude the
pen's position from the latest timestamp.
A light pen is fairly simple to implement. Just like a light gun or electron gun, a
light pen works by sensing the sudden small change in brightness of a point on the
screen when the electron gun refreshes that spot exactly where the scanning has
reached at that moment, the X, Y position of the pen can be resolved.
This is usually achieved by the light pen causing an interrupt, at which point the scan
position can be read from a special register, or computed from a counter or timer. The
pen position is updated on every refresh of the screen.
The light pen became moderately popular during the early 1980s.
It was notable for its use in the IBM PC compatible CGA, in some EGA graphics cards.
The first light pen was created around 1952 as part of the Whirlwind project at MIT.
Since light pens operate by detecting light emitted by the screen phosphors, some
nonzero intensity level must be present at the coordinate position to be selected.
A light pen is similar to a mouse, except that with a light pen you can move the
pointer and select objects on the display screen by directly pointing to the objects
with the pen.
Unit II
Contents:-
2.1) Introduction 2.2) Line, Line
Segment…………………………………. 2 2.3) Line
Drawing Algorithms…………………...……… 3 a) Digital
Differential Algorithm, (DDA)…………… 4
b) Bresenham’s line Algorithm……………………… 6
2.4) Two dimensional transformation…………………… 12
2.5) Matrix Representation………………………………. 13
2.6) Translation…………………………………………… 14
2.7) Rotation……………………………………………… 17
2.8) Scaling……………………………………………..… 20
2.9) Reflection…………………………………………… 22
2.10) Shear………………………………………………… 25
By: Chimle M. D. 1 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
The screen of computer is divided into rows & columns. The intersection area of
these rows & columns is known as a pixel.
In order to draw a line on screen first we have to determine which pixels are to be
switched on or brightened or glow.
The choice of the pixel is determined by the orientation of the line which is to be
drawn.
There is a little difficulty in selecting the pixel for horizontal, vertical & diagonal
than any other orientation.
We must represent a line at distinct position & determine the nearest pixel to the
line at each sampled position.
By: Chimle M. D. 2 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
y=m.x+b;
The two endpoints of line segment are specified at positions P1 and P2 that is:
y P2(x2,y2)
b P1(x1,y1)
0 x
By: Chimle M. D. 3 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
ii. b= y1 – m.x1
By: Chimle M. D. 4 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
y = y + yincrement;
i=i+1
}
end while
Step6: Finish
Example 1: Consider the line from (0, 0) to (5, 5). Represent this line using
DDA line drawing algorithm.
Ans:-
3. Find length
If(abs(dx)>abs(dy)),Then:
Length=dx;
Else
Length=dy
Hence 5>=5 Therefore length=5
By: Chimle M. D. 5 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Example 2: Consider the line from (0, 0) to (6, 8). Represent this line using
DDA line drawing algorithm.
Ans:-
3. Find length
If(abs(dx)>=abs(dy)),Then:
Length=dx; else
Length=dy
Hence 6>=8 Therefore length=8
b) BRESENHAM’S ALGORITHM:
By: Chimle M. D. 6 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
This algorithms is originally developed for use with digital plotter, and can
also be used for CRT based devices.
The algorithm searches to selects the best location that represents a straight
line. To achieve this, the algorithm always increment by one units in either x
or y depending on the slope of the line.
The algorithm is cleverly constructed so that only the sign of the error term
need be examined.
The Line end points are (x1, y1) and (x2, y2) ,Consider these are not equal.
Step 1: [Initialize the variable]
x=x1
y=y1
By: Chimle M. D. 7 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
e=e - 1
end while
x=x+1
e=e + m
next i
step6: Finish.
Example 1:
Consider the line from (0, 0) to (5, 5). Represent this line using Bresenham’s line
drawing algorithms for first octant. ANS: Initial calculation:
x=0 y=0
Δx=5
Δy=5
m=1
e=1-1/2=1/2
By: Chimle M. D. 8 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
The point (5, 5) is not activated or brightened. So you have to change the loop
from for i=0 to Δx.
In Bresenham’s Algorithms only the sign of the error term is important. So for
calculating the error term Bresenham’s introduces new formula.
i.e. e= 2 * Δy -Δx
Using this there is no need to perform floating point operation in algorithm. This
algorithm can be easily implemented in hardware or software
The Line end points are (x1, y1) and (x2, y2) .Consider these are not equal.
Step3: [Calculate e]
e= 2*Δy - Δx
By: Chimle M. D. 9 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
To draw a line on any octant we have to determine the octant in which the
given points belong or fall, and we have to calculate the slope of the line.
When the absolute value of the slope of the line is greater than 1, then y is
incremented by 1.
And error value e is used to determine, when the value of x will be incremented.
The Line end points are (x1, y1) and (x2, y2) .Consider these are not equal.
All variables are considered as integer.
The sign function is used to check the sign (plus or minus) of (x2- x1) or
(y2y1).
By: Chimle M. D. 10 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
By: Chimle M. D. 11 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
For i=1 to Δx
setpixel(x,y)
while (e>0)
if(interchange=1)
x=x+S1
else
y=y+S2
end if
e=e-2*Δx
end while
if(interchange=1)
y=y+S2
else
x=x+S1
end if
e=e+2*Δy
next i
Step7: Finish.
Example 1:
To understand the general bresenham’s algorithm consider the line from (0,
0) to (-8, -4). Represents the line using general bresenham’s algorithm.
Ans:
Initial calculation:
x=0 y=0
Δx=8
Δy=4
S1=-1
S2=-1
Interchange=0 e=0;
By: Chimle M. D. 12 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
i Setpixel e x y
0 0 0
1 (0, 0) 8 -1 0
2 (-1, 0) -8 -1 -1
0 -2 -1
3 (-2, -1) 8 -3 -1
4 (-3,-1) -8 -3 -2
0 -4 -2
5 (-4, -2) 8 -5 -2
6 (-5, -2) -8 -5 -3
0 -6 -3
7 (-6, -3) 8 -7 -3
8 (-7, -3) -8 -8 -4
0
e3
e1
e2 p2
P1
x
0
In above figure object triangle is made up of points (P1, P2, and P3) & edges or
lines (e1, e2, and e3).
By: Chimle M. D. 13 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
The ability to transforms these lines & points is achieved by translation, rotating,
scaling & reflection.
Two points of view are used for describing the objects movement.
Row-Major Order
Column-Major Order
By: Chimle M. D. 14 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
D(x1, y2)
D (10, 100) C(x2, y2)
C (100, 100)
Let A(10,10) & C(100,100) be the opposite vertices of the rectangle, then we can
identify the B & D is B(100,10) and D(10,100).
Then we have to store each point in matrix of row major order as follows:
A x1 y1 10 10
[x]=
B = x2 y1 = 100 10
C x2 y2 100 100
D x1 y2 10 100
2.6) Translation:-
“Changing the position of objects along a straight line path is called translation”.
OR
“Repositioning objects along straight line path is called translation.”
For translation of two dimensional points we have to add translation distance in it.
Let the translation distance tx and ty for x and y direction respectively.
Then we can simply add this translation distance to original x and y as follows:
X’= x+tx and y’= y+ty
The translation distance pair (tx ty) is called translation vector or shift vector. The
standard translation matrix given for translation of any 2-D object is as shown
below:
[T]= 1 0 0
By: Chimle M. D. 15 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
0 1 0
tx ty 1
This is simply a unit matrix in which diagonal elements are 1 and tx and ty are the
translation vector or distance on x and y direction respectively.
For transformation of original point P(x, y) of object is represented in matrix as :
[x]= [x y 1]
[x*]= [x* y* 1]
[X*] = [X].[T]
= [x y 1]. 1 0 0
0 1 0
1
tx ty
=[x+ tx y+ ty 1]
Example 1:-
Consider the object triangle whose point are A(2,2) B(4,2) and C(3,3). Translate
the object by using translation distance or vector on x direction t x=2 and translation
distance or vector on y direction ty=2.
Solution:
2 2 1
[X]=
4 2 1
3 3 1
1 0 0
[T]=
0 1 0
2 2 1
[X*] = [X].[T]
2 2 11 0 0
= 4 2 1. 0 1 0
3 3 12 2 1
4 4 1
= 6 4
1
5 5 1
By: Chimle M. D. 17 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
c*(5,5)
5
4 a*(4,4) b*(6,4)
c(3,3)
3
2
a(2,2) b(4,2)
1
x
1 2 3 4 5 6
2.7) Rotation:-
To generate a rotation, we specify a rotation angle ϴ and the position (xr,yr) of the
rotation point about which the object is to be rotated.
Positive values for the rotation angle define counterclockwise rotations. Negative
values rotate objects in the clock wise direction.
By: Chimle M. D. 18 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
P`(x`, y`)
ϴ
r`
p(x, y)
ϴ r
Ф x
0
In the above figure r is the constant distance of point from the origin. ϴ is the rotation
angle and Ф is the original angle from origin.
Using the standard trigonometric function we can express or represent the transformed
co-ordinates in terms of ϴ and Ф
Y`=[Link]ϴ + [Link]ϴ
[X*]=[X].[T]
By: Chimle M. D. 19 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
[T]= cosϴ -
sinϴ
sinϴ cosϴ
2] Anticlockwise:
Example:
Consider an object ABC with co-ordinates A(1,1) B(10,1) C(5,5) rotate the object
in 900(degree) anticlockwise direction. And give co-ordinates of transformed
object.
[X]= 1 1
10 1
5 5
Rotation operation will be performed as follws.
[X*]=[x].[T]
= 1 1 0 1
10 1 . -1 0
5 5
= 0-1 1+0 -1
1
0-1 10+0 = -1
10
By: Chimle M. D. 20 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
0-5 5+0 -5 5
B`(-1,10) 10
8
Rotation object Original object
C`(-5,5) 6
C(5,5)
4
2
A`(-1,1) A(1,1) B(10,1) x
-10 -8 -6 -4 -2 0 2 4 6 8 10
2.8) Scaling:
This change can be either positive or negative. Means the size can be increased if
the change is positive and size can be decreased if the change is negative.
In scaling the parameter Sx and Sy denotes the scale change in the coordinates x
and y respectively.
After applying the scaling vector or matrix of any object, the coordinates is either
increased or decreased depending upon the value of scaling vector Sx and Sy.
By: Chimle M. D. 21 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
If the value of Sx and Sy is greater than 1 the size of object will be increased and if
the value of Sx and Sy is less than 1 then the size of object will be decreased.
Sx
0
[T]=
0
Sy
Example 1:
Scale the object with coordinates A(1,1) , B(3,1), C(3,3) and D(1,3) with a scaling
vector Sx= 2 and Sy= 2.
Solution:
1 8
[X]= 3 1 16
3 23
1 23
[T]= 2 0
0 2
By: Chimle M. D. 22 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
[X*]= [X].[T]
1 1
=
3 1
2 0
3 3 *0 2
1 3
2+0 0+2 2 2
= 6+0 0+2 =6 2
6+0 0+6 6 6
2+0 0+6 2 6
When we represent object using this point the object will look like as shown in fig.:
y
6
d*(2,6) c*(6,6)
5
4
a*(2,2)
3
b*(6,2)
2
1
x
1 2 3 4 5 6
2.9) Reflection:
By: Chimle M. D. 23 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
y=-x y y=x
Y’
Point A when reflected on y axis, is displayed as A2, and A when reflected about x
axis is displayed as A1.
Original position
Reflected position
By: Chimle M. D. 24 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Reflected position
Original position
Reflection of an object relative to
an axis perpendicular to xy plane and
passing the coordinate origin.
Using reflection we can keep the image as it is but on opposite octant or quadrant. So
we need an identity matrix with positive or negative value depending upon the
situation.
Reflection about x axis (i.e. y=0 axis)
[T]= 1 0
0 -1
By: Chimle M. D. 25 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
-1 0
[T]= 0 1
[T]= 0 1
1 0
Reflection about y=-x axis is
[T]= 0 -1
-1 0
[T]= 1 0
0 -1
4 1 1 0
[X*]= 5 2 . 0 -1
4 3
By: Chimle M. D. 26 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
-1
-2
-3
-4
x
2.10) Shearing:-
Changing means not increasing or decreasing the shape. Creating the new shape from
existing shape by destroying the existing shape.
In shearing the opposite and parallel layers of any objects are simply slides with
respect to each other.
Shearing can be done either in x direction or y direction.
[T]= 1
shy Shx
1
Example 1:
Consider the object whose points are A(1,1) B(3,1) C(3,3) and D(1,3) with a shearing
vector shy=2 and shx=0.
By: Chimle M. D. 27 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
1 1
[X]= 3 1
3 3
1 3
[T]= 1 2
0 1
So, the shearing operation will be performed as follows.
[X]= [X].[T]
1 1 1 2
= 3 1 . 0 1
3 3
1 3
1+0 2+1 1 3
= 3+0 6+1 = 3 7
3+0 6+3 3 9
1+0 2+3 1 5
When we represent object using this point the object will look like as shown in
fig.:
By: Chimle M. D. 28 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
c*(3,9)
9
7 b*(3,7)
6
D*(1,5)
5
4
a*(1,3)
3 c(3,3)
1
a(1,1) b(3,1)
1 2 3 4 5 x
By: Chimle M. D. 29 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
UNIT III
Contents:
3.1) SEGMENT TABLE:- .................................................................................................................. 2
3.2) FUNCTIONS FOR SEGMENTING DISPLAY FILE ................................................................ 4
1) Create segment:- ......................................................................................................................... 4
2) Close segment:- .......................................................................................................................... 5
3) Delete segment:- ......................................................................................................................... 5
4) Rename segment:- ...................................................................................................................... 5
3.3) POSTING AND UNPOSTING SEGMENT ...............................................................................
6
3.4) SEGMENT NAMING SCHEME:- ............................................................................................ 7
3.5) DEFAULT ERROR CONDITION .............................................................................................
8 1) Opensegment(n):-
....................................................................................................................... 8 2)
Closesegment(n):- .......................................................................................................................
8 .3) Deletesegment(n):-
.................................................................................................................... 8 4) Postsegment(n):-
......................................................................................................................... 8
4.5.5) Unpostedsegment(n):- .......................................................................................................... 8
3.6) APPENDING TO SEGMENT
.................................................................................................... 8
3.7) Viewing Transformtion ...................................... Error! Bookmark not
defined.
3.8) 2-D Clipping ........................................................................................................
11
3.9) Simple Visibility Algorithm ................................................................................
12
3.10) End Point Codet .................................................................................................
13 3.11) Midpoint Subdivision algorithm
....................................................................... 15
By: Chimle M. D. 1 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Segment is a unit of display file to use the segment we must know display file is used for
representation of picture on screen and segment is a part of display file.
The segment is a logical unit it may be continuous or not continuous area of display or on
the screen.
It is a simply a collection of display file instruction which represents a part of graphics that
can manipulate as a single unit.
1) Segment are used to define and modify the picture in a set of sub pictures.
2) Segment is a output primitive or operations that are joined for modification purpose.
Graphics program generates output in a segmented display file then display processor read
the input and stored in refresh display file then finally display controller displays the output
on screen as shown below:
By: Chimle M. D 2 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Segment format:
Segment Name
Segment parameters
Output primitives
End of segment
pointer field
Next pointer field indicates the address of next segment visibility pointer field indicates
visible area of segment.
By: Chimle M. D. 3 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Generally the graphics program generates the graphics output in a display file instead of
displaying directly on the screen.
The display controller card available in system display the content of display file on screen.
Segmenting the display file means creating the part of display file for displaying changing
& modifying the graphics on screen when program is in running mode.
Creating dynamic graphics we can create the segment or parts of program of set of functions for display file
manipulation.
The common method of creating and modifying sequential disk file is to open a file before
we add data to it and close the file when we have added the last data item and the file is
complete.
To change the content of file we open it again add the new data to replace the old and close
the new file.
The every same operation can be used for manipulating display file segment.
To create a new segment we open it and then use the graphics functions to add line, circle,
rectangle and text etc. The segment to be displayed then we close the segment.
1) Create segment
2) Close segment
3) Delete segment
By: Chimle M. D 4 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
4) Rename segment
1) Create segment:-
In segment creation process, initially we have to check weather some other segment is still
open.
It is not allow to open two segment at a same time. Because it is difficult to assign the
drawing instruction to particular segment.
Segment must be created and opened when no other segment is currently open.
We have not entered any instructions into the segment it`s size is initialized with zero and
attribute of the segment are initialize as a default value.
2) Close segment:-
Once a segment is open, We can enter the display file instructions in it.
If there are two unnamed segment in the display file; one has to be deleted.
3) Delete segment:-
When we want to delete a particular segment from the display file. Then we must recover the
storage space and make this space free for some other segment use of array`s makes the
recovery of the storage space accupies by the segment.
By: Chimle M. D. 5 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
EX:- Deletesegment(T);
Where, T is the segment name.
4) Rename segment:-
We have to delete current segment and recreate it with the altered characters.
This process is complex so we can avoid this problem by keeping the next image ready in
the display file before deleting the current segment.
EX:-Renamesegment(T);
We can extend the unusefulness of our graphics package consider by allowing segments to
become temporarily invisible for this we need two additional functions.
Posting is a action of including a segment in the display refresh cycle thus posting makes
segment visible.
Unposting removes the segment from the refresh cycle, so that it is no longer visible.
These segment is not destroyed by unposting and so it can be visible again without
predefining it simply by posting it .
By conversion we assume that new segment is in the unposted state immediately after they
have been defined and closed. Thus a segment call is always necessary before a segment
become a visible.
Posting and unposting are particularly useful in avoiding the need for repeatedly redefining
graphics edges, commands, menus and other segment that are removed only temporarily
from the screen.
By: Chimle M. D 6 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
The most common scheme for naming segment is to provide each segment with unique
integer name.
Normally text strings are more popular as names but if we assign integer names to segment
in a program then we can easily manipulate the segment.
Integer names are more useful and easy to remember than string names and more easily
manipulated than string.
Integer names are more convenient for making relation with segment.
Integer names are more easily manipulated when storing a segment into data structure like
array.
Suppose there are so many segments in the program we have created, internally all these
segment will be stored in array.
Then for accessing any segment from the array we can use the index as a segment name as
follows:
By: Chimle M. D. 7 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
2
1
Segment 2
While creating and using the segment in a program we can make one or more programming
displays with the five functions:-
1) Opensegment:
2) Closesegment:
3) Deletesegment:
4) Postsegment:
5) Unpostsegment:
For e.g:-1) We can forgot to close segment and then they try to open another. or
2) We can try to delete a segment which is not present. or 3) We
can try to close a segment which is not present.
There are several solutions to the class If problem we can simply display an error message.
By: Chimle M. D 8 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Any currently open segment is closed then we can open a new segmet.
2) Closesegment(n):-
.3) Deletesegment(n):-
Any currently open segment is closed if segment n doesnot exist no further effect.
4) Postsegment(n):-
Any currently open segment is closed if segment n is non existent or already posted, no
effect.
5) Unpostedsegment(n):-
These default actions take case of the more common mistake of error.
Adding a new drawing or picture to the existing segment is called Appending to segment.
By adding new drawing to existing segment we can change the picture at run time.
For e.g:- A program to display the result of two concurrent processes in the form of two
graphs plotted on the same axes as shown in following figure:-
By: Chimle M. D. 9 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
x
0
Fig:-Plotting the result of two concurrent processes.
Every two minute each process generates a new data point and the graphs are extended.
One method of writing such program would be to create a new segment for each addition
made to be either graph.
This would be a time consuming on the other hand any alternative approach such as the use
of the single statement for each graph could involve reconstructing the entire segment after
every step.
Appendsegment(n)
3.8) 2D Clipping:
Removing the portion outside the window area or window region is called clipping.
By: Chimle M. D 10 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
For getting the portion of any picture we need to clip the picture, means we need to
remove the unwanted part of picture.
For removing any unwanted part we have first specify the window or define the
window.
Many application programs such as Adobe Photoshop, MS-Word provide the facility of
removing the unwanted part from picture or drawing.
For writing such application program of our own we need to understand the clipping
procedure.
Window: A world-coordinate area selected for display is called a window. Viewport: An
area on a display device to which a window is mapped is called a viewport.
The window defines what is to be viewed; the viewport defines where it is to be displayed.
Clipping: Removing the portion outside the window area is called clipping.
To understand clipping first we start from point clipping
How the points are clipped that you can understand using following fig:
In the above figure the points P1 & P2 are inside the window that is defined & point p3 and
p4 are outside the window.
When we perform the clipping operation only points with in the window will be visible as
shown in following fig
By: Chimle M. D. 11 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Line Clipping:
Line clipping is an operation through which, the unwanted portion of line is removed.
To understand the line clipping consider the following figure.
In the above figure the Line P1 & P2 is inside the window & lines p3 to p4 and p6 to p7 is
partially in window and p8 to p9 is totally outside the window.
When we perform the clipping operation only lines with in the window will be visible as
shown in following fig
By: Chimle M. D 12 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
In the above figure line p1 to p2 is totally visible line and line p3 to p4 and p6 to p7 is
partially visible lines and line p8 to p9 is totally not visible line.
If p1 & p2 are the two end points of the line then the algorithms for identifying visible, not
visible & partially visible lines is:
By: Chimle M. D. 13 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
By: Chimle M. D 14 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Thus, an endpoint that is below and to the left of the clipping window is assigned the region
(0101).
The region code for any endpoint inside the clipping window is (0000).
1. A value of 1 (true) in any bit position indicate that the endpoint is outsides of that
border.
2. A value of 0 (false) indicates that the endpoint is inside or on that border.
Every end-point of line is labeled with the appropriate region code as shown in following
fig.
By: Chimle M. D. 15 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Lines completely contained within the window boundaries have region code [0000] for both
end-points so are not clipped
Any lines with 1 in the same bit position for both end-points are completely outside and
must be clipped.
For example a line with 1010 code for one endpoint and 0010 for the other (line P11, P12)
is completely to the right of the clipping window. •We can perform inside/outside test for
lines using logical operators.
•When the OR operation between two endpoint codes is false (0000), the line is inside the
clipping window, and we save it.
•When the AND operation between two endpoint codes is true (not 0000), the line is
completely outside the clipping window, and we can eliminate it.
By: Chimle M. D 16 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
2. If the end point are not visible. Means two end points are completely outside the
windows area as shown in following fig. then we simple ignore the line. The
process is complete.
3. If one end point of line in outside the window & one is inside the window or both
the end point are outside the window area but line is passing through window area
as shown in fig. then we have to calculate midpoint.
By: Chimle M. D. 17 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
4. Suppose p1(x1, y1) and p2(x2, y2) are points of line p1 and p2 then mid value is:
Pm = xm = (x1+x2)/2 and ym = (y1+y2)/2 So new
line is p1 pm and pm p2.
5. Again we check if their end points are in visible area of clipping window. If not we
further divide p1 pm into two line segments i.e. p1 pm1 and pm1 pm
6. This procedure will continue until all part of line are either visible or invisible
totally
7. If any part of line is partially visible then we continue with process again
Example:
A Clipping window ABCD is specified as A (100,100), B(300,100) ,C (300,300) and
D(100,300) using midpoint subdivision algorithm find the visible portion of the line with
points p1(50,200) and p2(250,200)
Solution
Using the above points the window & line will look like as shown in fig.
By: Chimle M. D 18 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Here xm is equal to 100 because window starts from this. We can consider this point for
clipping lines means new p1 of line will be (100,200) and p2 (250,200).
After this if we redraw the clipped line, line will be displayed as shown in fig:
By: Chimle M. D. 19 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
It uses a divide and conquers strategy. It solves a series of simple and identical
problems that, when combined, solve the entire problem. The simple problem is to clip
a polygon against a single infinite clip edge. Four clip edges, each defining one
boundary of the clip rectangle successively clip a polygon against a clip rectangle.
A technique for clipping areas developed by Sutherland & Hodgman
Put simply the polygon is clipped by comparing it against each boundary in turn
By: Chimle M. D 20 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
There are four possible cases when processing vertices in sequence around the
perimeter of a polygon. As each pair of adjacent polygon vertices is passed to a
window boundary clipper, we make the following tests:
(1) If the first vertex is outside the window boundary and the second vertex is
inside, both the intersection point of the polygon edge with the window boundary
and the second vertex are added to the output vertex list.
(2) If both input vertices are 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 boundary is added to the
output vertex list.
(4) If both input vertices are outside the window boundary, nothing is added to
the output list.
By: Chimle M. D. 21 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
By: Chimle M. D 22 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Unit IV
Contents:-
4.1) GEOMETRIC MODELING: ............................................................................................. 2
4.1.1) Displaying Geometric Model: ........................................................................ 2
4.2) SYMBOLS AND INSTANCES: ...................................................................................... 3
4.3) IMPLEMENTATION OF INSTANCE TRANSFORMATION( Foming the
instance Transformation): ............................................................................................................ 5
4.4) Ground rules for graphics software design: .................................................................... 7
i) simplicity- ............................................................................................................. 8
ii) Consistentency-................................................................................................. 8
iii) Completeness-................................................................................................. 8
iv) Robustness- ..................................................................................................... 8
v) Performance- .................................................................................................... 8
vi) Economy- ........................................................................................................ 9
4.5) Functional domains: ............................................................................................................. 9
i) Graphics primitives-............................................................................................ 9
ii) Windowing functions- ....................................................................................... 9
4.6) Graphics primitives:.............................................................................................................. 9
By: Chimle M. D. 1 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
By: Chimle M. D. 2 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
While displaying the model some common features are used in nearly all geometric
models.
• Basic elements of data in model.
• Structure of geometric model represents the relationship in each components
of model.
• Transformation operation that defines the position & orientation of each part
of the modeled objects. In a model many instances of the same components
can be displayed as shown in above figure by applying various transformation
operations.
By: Chimle M. D. 3 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
By: Chimle M. D. 4 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Using such functions we can place symbol in a variety of different ways. The
order in which the functions are called affects the resulting instance
transformations.
We generally call scale before Rotate and call Translate last of all.
Instance transformations produces world coordinates; we must use the viewing
transformations operation.
How we define symbols and invoke instances of them is shown in following
example.
By: Chimle M. D. 5 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
Fig: Picture with multilevel structure showing the sub picture, symbols, and
symbol components
To display components rectangle indicated in above figure we must apply instance
transformation of the rectangle relative to door, then concatenate this with the
instance transformation of the door relative to the house and finally concatenate the
instance transformation of entire house.
While performing instance transformation operation we can perform clipping
operation before or after the instance transformation.
By: Chimle M. D. 6 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
By: Chimle M. D. 7 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
ii) Consistentency-
- A consistent graphics system is one that behaves in generally predictable
manner.
- Function names, calling sequences, error handling and coordinate systems all
should follow simple and consistent patterns without exceptions.
iii) Completeness-
- There should be no irrigating omissions in the set of functions provided by the
system.
- The system designer must be try to design a reasonably small set of function
that can conveniently handle a wide range of application.
iv) Robustness-
- Application programmers are capable of extraordinary misuse of graphics
system.
- The system should accept such treatment with minimum of complaint.
v) Performance-
- Graphics system performance is often limited by such factors as operating
system response and display characteristics, factors beyond the system designer’s
control.
- Graphics system designer except to minimum the effect by omitting highly
dynamic graphic functions that demand fast response or expensive hardware.
By: Chimle M. D. 8 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
vi) Economy-
- It is always to write an application program is too bulky or too expensive to use.
i) Graphics primitives-
These are used to display straight lines, text strings, circular arcs and other
simple graphical items.
By: Chimle M. D. 9 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics
By: Chimle M. D. 10 / 10