0% found this document useful (0 votes)
18 views81 pages

Computer Graphics Overview and Applications

Computer Graphics Notes

Uploaded by

hp895682
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views81 pages

Computer Graphics Overview and Applications

Computer Graphics Notes

Uploaded by

hp895682
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

Unit I

Introduction To Computer Graphics


Contents:-
1.1) Introduction……………………………………………………………… 2
1.2) Application area of computer graphics ...……………………………….. 3
1.3) Advantages of computer graphics……………………………………….. 4
1.4) Graphical user interface…………………………………………………. 5
1.5) Random scan displays………… …………………………………......... 7
Raster scan displays…………………………………………………….. 8
1.6) Display devices:………………………………………………………… 8
Cathode Ray Tubes …………………………………………………….. 9
Color CRT monitors …………………………………………………… 12
Direct View Storage Tube……………………………………………… 14
1.7) Plotter…………………………………………………………………… 15
1.8) Joystick………………………………………………………………… 16 light
pen………………………………………………………………… 17

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

By: Chimle Mahesh 1 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

“Computer graphics are graphics created using computers and the representation of
image data by a computer by using specialized graphic hardware and software.”

Computer graphics is made up of number of pixels. Pixel is the smallest graphical


picture or unit represented on the computer screen.

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

Computer graphics is everywhere today. The Computer imagery is found on television,


in newspapers, for example in weather reports, or for example in all kinds of medical
investigation and surgical procedures.

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 monitor is a display monitor that can display 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.

By: Chimle Mahesh 2 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

graphics applications are: paint program, design program, presentation graphics


software, animation software and desktop publishing.

1.2) Applications of Computer Graphics:

Following are the applications of computer graphics.


1. User interfaces: It is now a well-established fact that graphical interfaces
provide an attractive and easy interaction between users and computers.
The built-in graphics provided with user interfaces use visual control items such as
buttons, menus, icons, scroll bar etc. which allows user to interact with computer only by
mouse-click. Typing is necessary only to input text to be stored and manipulated.

2. Plotting of graphs and chart: In industry, business, government, and


educational organizations, computer graphics is most commonly used to create 2D and
3D graphs of mathematical, physical and economic functions in the form of histograms,
bars and pie-charts. These graphs and charts are useful for decision making.

[Link]/CAM( Computer-aided drafting and design / Computer Aided


Design/Computer Aided Manufacturing) the computer –aided drafting uses graphics to
design components and systems electrical, mechanical, electromechanical and electronic
devices such as automobile bodies, structures of building, airplane, ships, very large
scale integrated chips, optical systems and computer networks.

4. Simulation and Animation: use of graphics in simulation makes


mathematic models and mechanical systems more realistic and easy to study. The
interactive graphics supported by animation software proved their use in production of
animated movies and cartoons films.

5. Art and Commerce: There is a lot of development in the tools provided by


computer graphics. This allows user to create artistic pictures which express message
and attract attentions. Such pictures are useful in advertising.

6. Process Control: By the use of computer now it is possible to control


various processes in the industry from a remote control room. In such cases, process

By: Chimle Mahesh 3 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

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.

7. Cartography: Computer graphics is also used to represent geographic maps,


weather maps, oceanographic charts, counter maps, population density maps and so on.

8. Education and training: computer graphics can be used to generate


models of physical aids, models of physical systems, physiological systems, population
trends, or equipment, such as color –coded diagram can help trainees to understand the
operation of the system.

1.3) Advantages of Computer Graphics:


The main advantages of computer graphics are as follows:-

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.

2. It have ability to show moving pictures and thus it is possible to produce


animations with computer graphics.

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.

By: Chimle Mahesh 4 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

1.4) Graphical user interface:


GUI is an interface that allows users to interact with different electronic devices
using icons and other visual indicators. The graphical user interfaces were created
because command line interfaces were quite complicated and it was difficult to
learn all the commands in it.

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

Elements in Graphical User Interface


Graphical User Interface makes use of visual elements mostly. These elements define the
appearance of the GUI. Some of these are described in detail as follows :

By: Chimle Mahesh 5 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

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.

By: Chimle Mahesh 6 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

1.5) Random scan displays:


In this technique, the electron beam is directed only to the part of the screen where
the picture is to be drawn rather than scanning from left to right and top to bottom
as in raster scan. It is also called vector display, stroke-writing display, or
calligraphic display.

Picture definition is stored as a set of line-drawing commands in an area of memory


referred to as the refresh display file. To display a specified picture, the system
cycles through the set of commands in the display file, drawing each component
line in turn. After all the line-drawing commands are processed, the system cycles
back to the first line command in the list.

Random-scan displays are designed to draw all the component lines of a picture 30
to 60 times each second.

❖ Raster scan displays:


Raster: A rectangular array of points or dot.

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.

By: Chimle Mahesh 7 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

A raster image is a collection of dots called pixels.


In a raster scan system, the electron beam is swept across the screen, one row at a time
from top to bottom.

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.

Fig: Raster Scan Display

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.

By: Chimle Mahesh 8 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

Suited for realistic display of screens.

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.

1.6) Display Devices:


A display device is an output device for presentation of information in visual or tactile
form (the letter used for example in tactile electronic displays for blind people). When
the input information that is supplied has an electrical signal, the display is called an
electronic display.

Common applications for electronic visual displays are televisions or computer monitors.
There are various designs for display devices, using various technologies.

Several components are common to most display devices.

i. A digital memory, or frame buffer, in which the displayed Image is stored as a


matrix of intensity values.
ii. A monitor.
iii. A display controller, which is a simple interface that passes the contents of the
frame buffer to the monitor. Inside the frame buffer the image is stored as a
pattern of binary digital numbers, which represent a rectangular array of picture
elements, or pixel.

The pixel is the smallest addressable screen element.


In the Simplest case where we wish to store only black and white images, we can
represent black pixels by 0's in the frame buffer and white pixels by 1's.

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

By: Chimle Mahesh 9 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

By: Chimle Mahesh 10 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

❖ Cathode -Ray Tube (CRT) MONITORS:

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.

The specifications for CRT monitors include:

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.

By: Chimle Mahesh 11 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

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.

Advantages of CRT Monitors:


1. Resolution and Aspect Ratio
They operate at any resolution, geometry and aspect ratio without the need for rescaling
the image.

2. Highest Resolutions
CRTs run at the highest pixel resolutions generally available.

3. Black-Level and Contrast


Produce a dark black and the highest contrast levels normally available. Suitable for use
even in dimly lit or dark environments.

4. Color and Gray-Scale Accuracy


CRTs produce the best color and gray-scale and are the reference standard for all
professional calibrations. They have a perfectly smooth gray-scale with an infinite
number of intensity levels.

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.

By: Chimle Mahesh 12 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

Disdvantages of CRT Monitors:


1. Sharpness
Imperfect focus and color registration also reduce sharpness. Generally CRT isnot
sharper than LCDs at other than native resolutions.

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.

❖ Color CRT Monitors:


CRTs to produce color displays. Coating phosphors of different compounds can produce
different colored pictures.

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:

By: Chimle Mahesh 13 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

[Link] Penetration method

[Link] Mask method.


[Link] Penetration method:
This CRT is similar to the simple CRT, but it makes use of multi colored phosphorus of
number of layers.
Each phosphorus layer is responsible for one color. All other arrangements are similar to
simple CRT.
It can produce a maximum of 4 to 5 colors
The organization is something like this - The red, green and blue phosphorus are coated
in layers - one behind the other.
Monitors use the beam penetration method for displaying color picture.
In this, the inside of CRT screen is coated two layers of phosphor namely red and green.
A beam of slow electrons excites only the outer red layer, while a beam of fast electrons
penetrates red layer and excites the inner green layer.
At intermediate beam speeds, combination of red and green light are emitted to show two
additional colors- orange and yellow.

Advantages
i. Less expensive
Disadvantages
i. Quality of images are not good as compare with other methods
ii. Four colors are allowed only iii.

[Link] Shadow - Mask method:


Some display system uses shadow mask methods to produce a much more range of
colors than beam penetration method.
In this, CRT has three phosphor color dots. One phosphor dot emits a red light, second
emits a green light and third emits a blue light.

This type of CRT has three electron guns and a shadow mask grid as shown in following
figure:

By: Chimle Mahesh 14 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

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

❖ DVST( Direct View Storage Tube):


It is an alternative method for maintaining or displaying an image on screen.
It stores the picture information inside the CRT instead of refreshing the screen.
A direct-view storage tube (DVST) stores the picture information as a charge distribution
just behind the phosphor-coated screen.
Two electron guns are used in a DVST. One, the primary gun, is used to store the picture
pattern.
The second, the flood gun, maintains the picture display as shown in the figure below.

By: Chimle Mahesh 15 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

Figure: Working of DVST

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.

By: Chimle Mahesh 16 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

As a result, they can produce continuous lines, whereas printers can only simulate
(put on) lines by printing a closely spaced series of dots.

Multicolor plotters use different-colored pens to draw different colors.

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.

Two commonly type plotters are:


i) Drum Plotters
ii) Flatbed Plotters

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:

By: Chimle Mahesh 17 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

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 allows an individual to move an object in a game such as navigating a


plane in a flight simulator. In the picture to the right, is of the Logitech Freedom 2.4
joystick and an example of what a Joystick may look like.

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.

By: Chimle Mahesh 18 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

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.

By: Chimle Mahesh 19 / 20


Class: BCASY ( Sem IV ) COCSIT, Latur Sub: Computer Graphics

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.

By: Chimle Mahesh 20 / 20


Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

Unit II

Raster Scan Graphics and Transformation

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

Raster Scan Graphics is a technique used to draw a graphics objects.


In this technique scanning is performed to select the point or pixel to brighten the
pixel.
The computer can produces raster images on raster devices only by turning the
appropriate pixel on or off.
The process of representing continuous graphics objects as a collection of distinct
pixels is called scan-conversion.

2.2) Line, Line Segment

A line segment is a connected, non-empty set. If V is a topological vector space,


then a closed line segment is a closed set in V.
However, an open line segment is an open set in V if and only if V is
onedimensional. More generally than above, the concept of a line segment can be
defined in an ordered geometry.

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 process of determining which combination of pixels provides the best


approximation to the desired line is known as Rasterization.

When Rasterization is combined with rendering of the picture in scan-line order,


then it is known as scan-conversion.

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

2.3) Line Drawing Algorithm:

General Requirement of Drawing a Line:


i. Lines must appear to be straight. ii. Lines should start &
end accurately. iii. Lines should have constant brightness
along their length.
iv. Lines should be drawn rapidly(quickly, fast)

A line in a computer graphics typically reference to a line segment, which is


a portion of straight line that extends indefinably in apposite direction. It is
defined by its two end points and the slope intercept equation for a line:

y=m.x+b;

where , m=slope of line and b= the y intercept of a line.

The two endpoints of line segment are specified at positions P1 and P2 that is:

P1=(x1,y1) and P2=(x2,y2);

y P2(x2,y2)

b P1(x1,y1)

0 x

We can determine the value for slope m and b intercept as:


i. m=(y2-y1) / (x2-x1);
=Δy/Δx

Hence, Δy=(y2-y1) and Δx= (x2-x1);

By: Chimle M. D. 3 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

ii. b= y1 – m.x1

a) DDA ( Digital Differential Analyzer):-

The Digital Differential Analyzer (DDA) is a scan conversion line algorithm


based on calculating either Δx or Δy.

Step1: Get the input value of two end points that is :


(x1,y1) and (x2,y2)

Step2: Calculate difference between two endpoints.


dx =x2-x1
dy =y2-y1

Step3: To identify the number of steps(length).


if(abs(dx) >= abs(dy)) ,then :
length=abs(dx)
else :
length=abs(dy)
end if

Step 4: Calculate the increment in x co-ordinate and y co-ordinate.


xincrement = dx / (float)length ,
yincrement = dy / (float)length
initial value of x and y is:
x=x1 and y=y1

Step 5: Put the pixel by successfully.


begin the main loop
i=0
while (i < length)
{
putpixel(Integer(x),Integer(y))
x = x + x increment;

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:-

1. Get the input values that are:


x1=0 ,y1=0 and x2=5 ,y2=5

2. Calculate difference between two endpoints dx=x2-x1=5-0=5 dy=y2-y1=5-0=5

3. Find length
If(abs(dx)>abs(dy)),Then:
Length=dx;
Else
Length=dy
Hence 5>=5 Therefore length=5

4. Calculate xincrement and yincrement That is xincrement=dx/(float)length=5/5=1


and yincrement=dy/(float)length=5/5=1 and x=0 and y=0.
5. Following table shows putpixel successfully.
Execution of main loop
I x y Putpixel(x,y)
0 0 0 (0,0)
1 1 1 (1,1)
2 2 2 (2,2)
3 3 3 (3,3)
4 4 4 (4,4)
5 5 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:-

1. Get the input values that are:


x1=0 ,y1=0 and x2=6 ,y2=8

2. Calculate difference between two endpoints dx=x2-x1=6-0=6 dy=y2-y1=8-0=8

3. Find length
If(abs(dx)>=abs(dy)),Then:
Length=dx; else
Length=dy
Hence 6>=8 Therefore length=8

4. Calculate xincrement and yincrement That is :


xincrement=dx/(float)length=6/8= 0.75 and yincrement=dy/(float)length=8/8=1
and x=0 and y=0.

5. Following table shows putpixel successfully.


Execution of main loop
i X Y Putpixel(x,y)
0 0 0 (0,0)
1 0.75 1 (0,1)
2 1.50 2 (1,2)
3 2.25 3 (2,3)
4 3 4 (3,4)
5 3.75 5 (3,5)
6 4.50 6 (4,6)
7 5.25 7 (5,7)
8 6 8

b) BRESENHAM’S ALGORITHM:

By: Chimle M. D. 6 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

Bresenham’s has provided a computationally attractive scan-conversion


algorithm commonly known as Bresenham’s scan-conversion algorithms for line
drawing.

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 increments in the other variable either zero or one is determined by


examining the distance between the actual line & nearest gird locations.,
This distance is called error.

The algorithm is cleverly constructed so that only the sign of the error term
need be examined.

1) Bresenham’s Algorithm for the first octant:

The Line end points are (x1, y1) and (x2, y2) ,Consider these are not equal.
Step 1: [Initialize the variable]
x=x1
y=y1

Step2: [Calculate Δx and Δy].


Δx =(x2-x1)
Δy = (y2-y1)

Step3: [Calculate slope]


m=Δy/Δx

Step 4: [Initialize error e]


e=m-1/2

step5: Begin the main loop


For i=1 to Δx
Setpixel(x,y)
While(e > 0)
y=y+1

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

Main loop execution:


i setpixel e x y
½ 0 0
1 (0, 0) -½ 0 1
½ 1 1
2 (1, 1) -½ 1 2
½ 2 2
3 (2, 2) -½ 2 3
½ 3 3
4 (3, 3) -½ 3 4
½ 4 4
5 (4, 4) -½ 4 5
½ 5 5

The result are shown in above table.

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.

2) INTEGER BRESENHAM’S ALGORITHMS FOR THE FIRST OCTANT:

Previous Bresenham’s Algorithms requires the use of floating point arithmetic to


calculate the slope of the line & to calculate the error term. So that algorithms
requires more time to execute.

To increase the speed of algorithms Bresenham’s introduces integer Bresenham’s


Algorithms.

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.

Step 1: [Initialize the variable]


x=x1
y=y1

Step2: [Calculate Δx and Δy].


Δx =abs(x2-x1)
Δy = abs(y2-y1)

Step3: [Calculate e]
e= 2*Δy - Δx

By: Chimle M. D. 9 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

step4: Begin the main loop For


i=1 to Δx
Setpixel(x,y)
While(e>0)
y=y+1 e=e
– 2* Δx end
while
x=x+1 e=e
+ 2* Δy
next i
step5: Finish.

3) BRESENHAM’S GENERAL ALGORITHMS:

This algorithm is used to draw a line on any octant.

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.

Whether x or y is incremented by + or – 1 (±1) depends on the quadrant. This


is shown as follows.

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

To identify octant in which the points fall or belong.

This function returns -1 if value passed to this function is <0(means


negative) .

if value passed to this function is 1, if value passed to this function is


>0(means positive).

By: Chimle M. D. 10 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

Bresenham’s General Algorithms for all octant.

Step 1: [Initialize the variable]


x=x1
y=y1

Step2: [Calculate Δx and Δy].


Δx =abs(x2-x1)
Δy = abs(y2-y1)

Step3: [for the sign]


S1=sign (x2-x1)
S2=sign (y2-y1)

Step4: [Interchange Δx & Δy depending upon the slope of the line].


if(Δy > Δx) ,then:
temp =Δx
Δx=Δy
Δy=temp
interchange=1
else :
interchange =0
end if

Step5: initialize the error term or error value e.


e=2 * Δy –Δx

Step6: [Main Loop starts]

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;

Loop execution, values of variable and plotting line.

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

2.4) Two dimensional transformation (Homogeneous


coordinate transformation):

Two Dimensional Transformations is commonly called as 2DTransformations. 2D


Transformation is performed on 2D objects. When the objects are represented
using 2 dimensional co-ordinates system then it is called 2D Objects.
2D objects is made up of set of points & set
of lines which P3 connects those points
as shown in figure: y

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 fundamental objective of 2D-Tranfromation is to represents the movement &


manipulation of objects in the 2D plane or 2D coordinates system.

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.

Transformations are used directly by application programs such as MS-Word,


MSPowerPoint, MS-Paint and may other Application use the geometric
transformation to change the position, orientation, and size of object.

2.5) MATRIX REPRESENTATION:-

In two-dimensional co-ordinates system any point is represented in terms of x & y


coordinates. The point (x,y) can be converted into matrix in the following two ways.

Row-Major Order
Column-Major Order

The above two matrix called position vectors.


A series of stored in a computer as a matrix or array of numbers.

Representation of a any 2-D object is matrix form:-


To represent any 2-D object in matrix form, we need to store all its points in rowmajor
order or column major order.

First we need identify the all points of objects.


Suppose we want to represents the following rectangle objects in matrix of row major
order.

A (x1, y1) B(x2, y1)

By: Chimle M. D. 14 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

A (10, 10) B (100, 10)

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]

Means 1 is added with every point.


Resultant transformation matrix will be represented as follow:

[x*]= [x* y* 1]

Here 1 is ignored while representing the transformed object or point. So the


transformation operation of translation is as follows:

[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 is added with every point.


By: Chimle M. D. 16 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

Translation matrix will be-

1 0 0
[T]=
0 1 0

2 2 1

So the translation operation will be performed as:

[X*] = [X].[T]

2 2 11 0 0
= 4 2 1. 0 1 0
3 3 12 2 1

2+0+2 0+2+2 0+0+1

= 4+0+2 0+2+2 0+0+1

3+0+2 0+3+2 0+0+1

4 4 1

= 6 4
1

5 5 1

When we represent this object, the objects will be shown as follows:


y

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:-

“Repositioning or movement of object along a circular path in xy coordinates is called


rotation”.
It is a process of changing the angle of the object.

A two dimension rotation is applied to an object by repositioning it along a circular


path in the xy plane.

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 default rotation point is considered as (0, 0).

Rotation of a single point on the screen is shown in fig:

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 Ф

Cos (ϴ+Ф) =x/r ………………………. 1.


X`=[Link] (ϴ+Ф)
X`=[Link]ϴ.cosФ – [Link]ϴ.sinФ x`= [Link]ϴ -
[Link]ϴ …………………………. 2.

Sin (ϴ+Ф) = y`/r ………………………………..3

Y`=r sin (ϴ+Ф)


Y`=[Link] Ф. sinϴ + [Link] Ф.cosϴ

Y`=[Link]ϴ + [Link]ϴ

This can represent in matrix from as:

[X*]=[X].[T]

ϴ can be clockwise (-ve) or counter clockwise (+ve) .

By: Chimle M. D. 19 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

Rotation matrix is:


1] Clockwise:

[T]= cosϴ -
sinϴ
sinϴ cosϴ

2] Anticlockwise:

[T]= cosϴ sinϴ


-sinϴ cosϴ

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.

Solution: Rotation is anticlockwise then value of ϴ is

[T] = Cos 90 -sin 90 = 0


1
Sin 90 cos 90 -1 0

[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

When we represent this object the object will be shown as follows:


y

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:

Changing the size of objects is called 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.

The scaling matrix given is:

Sx
0
[T]=
0
Sy

Where Sx and Sy are the scale changes in x direction and y direction.

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

Scaling matrix will be :

[T]= 2 0

0 2

So, the scaling operation will be performed as follows.

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

A reflection is a transformation that produces a mirror image of an object.

“Displaying the existing image in opposite direction is called reflection”. OR


“Reproduction or replication of existing image in opposite direction is called
reflection”.

y=-x y y=x

A2(-x, y)…………………………………………………… A(x, y)


.
.
.
.
X’ . x
.
.
.
.
A1(x,-y)

Y’
Point A when reflected on y axis, is displayed as A2, and A when reflected about x
axis is displayed as A1.

Reflection is also described as rotation by 1800.

The concept of reflection is shown in above figure:

Original position

Reflected position

Reflection about the x axis-

By: Chimle M. D. 24 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

Original position Reflected position

Reflection of an object about y axis-


y

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

Reflection about y axis (i.e. x=0 axis)

By: Chimle M. D. 25 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

-1 0
[T]= 0 1

Reflection about the line y=0 axis is

[T]= 0 1
1 0
Reflection about y=-x axis is

[T]= 0 -1
-1 0

Example:- Consider the triangle ABC whose coordinates are A(4,1)


B(5,2) and C(4,3). Reflect the triangle about x axis:
Solution:-
Transformation matrix for reflection about x axis is

[T]= 1 0
0 -1

Reflection operation will be performed as follows.


[X*]=[X].[T]

4 1 1 0
[X*]= 5 2 . 0 -1
4 3

[X*]= 4+0 0+ (-1) 4 -1


5+0 0+ (-2) = 5 -2 4+0 0+ (-3) 4 - 3
When we represent object using this point the object will replied as
follows: y
4
3
2
1
1 2 3 4 5

By: Chimle M. D. 26 / 29
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

-1
-2
-3
-4
x

2.10) Shearing:-

“Changing the shape or distortion of shape of object is called 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.

The off-diagonal turns in transformation matrix are responsible for shearing.

The matrix of shearing is:

[T]= 1
shy Shx
1

Following example show how shearing affects on shape of the objects.

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

Shearing matrix will be:

[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

Segmented Display Files and Clippeing and Windowing

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

3.12) Polygon clipping algorithm (Sutherland-Hodgman algorithm ) ............. 1Error!


Bookmark not defined.

3.1) SEGMENT TABLE:-

Segment is a part or unit of picture that is named for modification purpose.

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.

Segments are interlinked with one another in segmented display file.

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:

Segments are created in program using the following format.

By: Chimle M. D 2 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

Segment format:

Segment Name

Visibility pointer field

Next pointer segment


Field To next segment

Segment parameters

Output primitives

End of segment
pointer field

Fig:- Segment format


Segment parameters are the parameters passed to the segment output primitive are output
specification of segment.

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

3.2) FUNCTIONS FOR SEGMENTING DISPLAY FILE

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.

We have four basic functions for segments.

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 must give segment name and check it is valid or not.

To initialize the instructions of a segment located at next free storage area.

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.

After completion of entering all instruction, The segment must be closed.


To close segment it is necessary to change the name of the currently open segment say zero
that is unnamed segment.

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:-

Renaming segment we can display new image in the sequence.

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

3.3) POSTING AND UNPOSTING SEGMENT

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 .

The two functions to achieve this affect are:-


1) Postsegment(n) // Add segment n
2) Unpostsegment(n) // Remove segment n

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

3.4) SEGMENT NAMING SCHEME:-

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.

Segment names are used only within the program.

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:

Segment list Segment 1

By: Chimle M. D. 7 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

2
1

Segment 2

Fig:- List structure


representation of
segment

In this way we can easily determine the names of segment.

3.5) DEFAULT ERROR CONDITION

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:

By issuing functions calls in wrong order.

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.

We can handle this error message using following ways:


1) Opensegment(n):-

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

If no segment is currently open , no effect.

.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):-

Any currently open segment is closed if segment n is nonexistent or already unposted, no


effect.

These default actions take case of the more common mistake of error.

3.6) APPENDING TO SEGMENT

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.

In this situation like this a function is appends.

Appendsegment(n)

Open segment n for additions keeping it`s present content as it.

Append to segment function it is used to writing such applications programs.

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

3.9) SIMPLE VISIBILITY ALGORITHM:


This algorithm is used to identify weather the line is visible in windows area or
partially visible or not visible.
If both end points of the lines are inside in windows area then the line is totally visible.
If both end points of the lines are in outside the windows area then the line is totally
not visible.
And if one end points of the line is inside the windows area and another end point is outside
the windows area then the line is partially visible.

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:

Simple Visibility Algorithm:


1. Consider p1(x1, y1) and p2(x2, y2) are the end points of the line.
2. If both end points are left, right, bottom or top side of the window then the line is not
visible.
3. Consider WL (Window Left), WR (Window Right), WB (Window Bottom) and WT
(Window Top) are the four points of window that is defined.
4. Visibility =true // initializes variable to check visibility.

5. If (x1<WL and x2<WL) then Visibility=False


6. If (x1<WR and x2>WR) then Visibility=False
7. If (y1>WT and y2>WT) then Visibility=False
8. If (y1<WB and y2<WB) then Visibility=False

9. If (x1<WL and x1>WR) then Visibility=Partial


10. If (x2<WL and x2>WR) then Visibility=Partial
11. If (y1>WB and y1>WT) then Visibility=Partial
12. If (y2<WB and y2>WT) then Visibility=Partial

By: Chimle M. D. 13 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

13. If (Visibility=Partial) then


14. Print Line is partially visible.

15. If (Visibility=False) then


16. Print Line is not visible.

17. If (Visibility=True) then


18. Print Line is visible.

3.10) END POINT CODE:


For line clipping we need to identify both end points of lines are in window area or outside
the window area, or weather one end point is inside the window area & other is outside the
window area.
To check this we need to write conditions such as
If(x1>wx1 && y1>wy1 && x2<wx2 && y2<wy2) then
// Line is visible End if
Where (wx1, wy1) & (wx2, wy2) are the two point which represents window area.
And (x1, y1) & (x2, y2) represents the two end points of lines.
But writing such condition are not convenient & very time consuming. For
providing solution for this they have invented end point codes.

End Point Code is four digit binary codes.


Initially, every line endpoint is assigned a four digit binary value called a region code or
end point code, and each bit is used to indicate whether the point is inside or outside one of
the clipping window boundaries.
In a four bit end points code
i. First bit is 1 if the line endpoints are on exactly left side.
ii. Second bit is 1 if the line endpoints are on exactly right side. iii. Third
bit is 1 if the line endpoints are on exactly bottom side. iv. Fourth bit is 1 if the
line endpoints are on exactly top side. This is shown as follows

And all other bits are zero.


•The four window borders create nine Regions
•The Figure below lists the value for the binary code in each of these regions.

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.

3.11) MIDPOINT SUBDIVISION ALGORITHM:


Midpoint subdivision algorithm is used to find visible area of line on clipping window
(clipping window is that portion of picture or image that we want to view). This method is
based on bisection method i.e we calculate mid value of a line by adding end points of line
and then dividing that line by 2.
Steps:
1. If the end points are visible as shown in following fig. means two end points are in
window area then there is no need to calculate the midpoint of line for clipping line. The
process is complete.

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.

Line is partially visible. We need to calculate the midpoint.


Then : pm= xm=(x1+x2) /2 =(50+250)/2=150 ym=(y1+y2) /2
=(200+200)/2=200
Here xm is not equal to 100 because window start from 100. Then save the p2 as old
p2
Replace p2 as pm because pm is greater than 100
Then : p1(50,200) & new
p2(150,200)
Then :

By: Chimle M. D 18 / 22
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

pm= xm=(x1+x2) /2 =(50+150)/2=100 ym=(y1+y2) /2


=(200+200)/2=200

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:

3.12) POLYGON CLIPPING ALGORITHM (SUTHERLAND-HODGMAN


ALGORITHM):
Polygon is an object having closed outlines bounded by straight edges. An
example of polygon clipping is shown below.

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

Geometric Model and Simple Graphics


Packages

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

4.2) GEOMETRIC MODELING:


Geometric model is a model created using geometric
objects such as lines, rectangle, circle etc.
Non-geometric modeling (model which do not uses geometric object) is also used for
representation of physical processes, rather than geometric objects; an economic
model is an example of non-geometric model
In geometric modeling all the geometry or data of model is entirely stored in the data
structures.
We can just store the connectivity relationship of the circuits in the data structures
and use a procedure to compute the geometry of connecting lines.
Thus if the data structure indicates that the output of components A is to be
connected to the input of component of B.
One possible sequence is shown in fig.

To connect these two components we can write the following procedure.


Procedure LinksPoints(x1,y1,x2,y2)
MoveTo(x1,y1)
LineTo((x1+x2)/2,y1)
LineTo((x1+x2)/2,y2)
LineTo(x2,y2)
End

4.1.1) Displaying Geometric Model:


Once the geometric model is designed we can represents this model onscreen in
various forms as shown below

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.

4.2) SYMBOLS AND INSTANCES:


A Small picture designed to represents a particular thing is called symbol.
Multiple copy of the same symbol is called the instance of the symbol. The
use of graphical symbols is very common in charts and graphs like the one
shown in following fig.

By: Chimle M. D. 3 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

When we draw charts on a display, we must be able to define symbols so that


we can include instances of each symbol in the displayed chart.
The same feature is very useful in displaying plans of buildings, electric-circuit
diagrams, and drawing of mechanical objects.

The procedure of defining a symbol is similar to display other geometric object or


images for display.
There is only difference in use of coordinate system.
When we define a symbol, we do not know where it will be placed in the world
coordinate system; and we want to display it anywhere all over the world coordinate
space.
We must therefore define the symbol in a different coordinate system called the
master coordinate system.
To display each instance of the symbol, we define an instance transformation to be
applied to the master-coordinate definition to transform it into world coordinates.
Functions are needed for the specification of instance transformations. We
therefore add three new instance-transformation functions that allow us to
therefore add three new instance –transformations functions that allow us to define
the scaling, rotation, and translation to be applied to the symbol.

1. Scale(sx,sy) Scale the symbol by factors sx and sy in the x and y directions


relative to the origin.
2. Rotate() Rotate the symbol through degree clockwise about x axis.
3. Translate(tx,ty) Translate the symbol through distances tx and ty

measured in the x and y directions.

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.

Master Coordinate Rotate(45) Scale(0.3,0.3),


Definition Translate(12,10)
Fig: Gate Symbol Transformation:

This is generated using master coordinates definition of the symbol.


Following figure shows how the instance transformation function process in
performed.
The first figure shows instance transformation operation using world coordinate
system.
The second figure shows instance transformation operation using master coordinate
system.

4.3) IMPLEMENTATION OF INSTANCE TRANSFORMATION(


Foming the instance Transformation):
Instance transformation operation is performed as shown in figure.

By: Chimle M. D. 5 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

Such transformation can be expressed or represented using 3X3 matrix.


It is possible to concatenate the two transformation operation into single
transformation operation.
Means viewing matrix V is multiplied by the instance- transformation matrix N to
generate the combined transformations matrix M.
When we want to use two or more instance transformation operation then
transformation operation can be performed in sequence or in order. This if
we wish to generate the matrix Q from a scaling matrix S, rotation R & translation
T in an order.
Then the three matrices must be concatenated in the same order. Q=S
RT
When we want to concatenation of more than one component or part of picture to
one another as shown in following fig:

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.

• Clipping after the viewing transformation:


Clipping after the viewing transformation is shown in following figure:
This is a simplest choice but it involves transforming all lines in picture into screen
coordinate system weather they are visible or not.

By: Chimle M. D. 6 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

• Clipping between the instance and viewing transformation:


Clipping between the instance and viewing transformation is shown in
following figure.
It avoids the need to apply the viewing transformation to invisible lines.

• Clipping before instance transformation:


Clipping before instance transformation is as shown in following figure
This allows us to avoid applying any transformation to invisible lines. It is a difficult
process to implement.

4.4) Ground rules for graphics software design:


“A graphics system may be defined as any collection of hardware and software design
to make it easier to use graphic input and output in graphics program.”

By: Chimle M. D. 7 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

Or “graphics package is a set of subroutines


or functions used by an application program to generate pictures on display and
to handle graphical interaction.”
- Following are the basic concepts presented in the part one can be utilized in the
design of a simple graphics package.
i) Simplicity ii)
Consistency iii)
Completeness
iv) Robustness
v) Performance
vi) Economy
i) simplicity-
- Features that are too complex for the application programmer to understand
will not be used.
- One way to avoid these difficult features is to try to write user’s manual
before implementing the system.

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.

4.5) Functional domains:


- Anyone to designs graphics package is ignoring two points.
- First graphics package design must not be usually influenced by hardware
features or by highly specialized application requirements.
- Second, the functions in a graphic package can be separated into sets, each set
concern with a particular kind of task; it is then possible to address the issue
of completeness one set at a time.
- There are a number of such function sets to be considered in designing a
system ; in our first graphics package we should provide the following two
parts :

i) Graphics primitives-
These are used to display straight lines, text strings, circular arcs and other
simple graphical items.

ii) Windowing functions-


These allow the programmers to choose his coordinate system for picture
definition and to define a boundary of the visible portion of the picture.
- Other function sets include segmenting functions to permit easier modification
of a picture ;
- Two dimensional transformation functions for rotation, translation, scaling,
input-function that allow the users to give command with the help of a
keyboard or graphical input device.
- The initial phase of system design, they involves choosing a certain no. of
these sets to form the functional domain of the system.

4.6) Graphics primitives:


- Graphics primitives are the functions that we use to specify the actual lines
and characters that makeup the pictures.
- These functions most be chosen carefully to provide application programmer
with convenient methods of describing pictures and the some time to take
advantage of the capabilities of the display hardware.

By: Chimle M. D. 9 / 10
Class: BCASY(Sem IV) COCSIT, Latur Sub: Computer Graphics

- We should use a set of these primitive functions in our graphics package as


follows.
1) Move to X, Y:
Set current beam position (X, Y), for the next line or text string
2) Line to (X, Y) :
Draw a straight line from the current beam position to the point to (X,Y) and
reset the starting point to (X,Y).
3) Draw Text (S);
Display the string (S) with his lower left corner at the current beam position
to the string’s s lower right corner.
- This is a much smaller set of graphic primitives than one normally finds in
graphics package.

By: Chimle M. D. 10 / 10

You might also like