An Assignment Of:: Computer Graphics
An Assignment Of:: Computer Graphics
Computer Graphics
Assigned by:
Mam: Nazish Nawaz
Prepared by:
Sayed Rashid Ali Shah
2k18/CSM/101
APPLICATIONS OF COMPUTER GRAPHICS:
Computer Art:
Using computer graphics we can create fine and commercial art which
include animation packages, paint packages. These packages provide
facilities for designing object shapes and specifying object motion.
Cartoon drawing, paintings, logo design can also be done.
Presentation Graphics:
For the preparation of reports or summarizing the financial, statistical,
mathematical, scientific, economic data for research reports, managerial
reports, moreover creation of bar graphs, pie charts, time chart, can be done
using the tools present in computer graphics.
Entertainment:
Computer graphics finds a major part of its utility in the movie industry and
game industry. Used for creating motion pictures, music video, television
shows, cartoon animation films. In the game industry where focus and
interactivity are the key players, computer graphics helps in providing such
features in the efficient way.
Education:
Computer generated models are extremely useful for teaching huge number of
concepts and fundamentals in an easy to understand and learn manner. Using
computer graphics many educational models can be created through which
more interest can be generated among the students regarding the subject.
Training:
Specialized system for training like simulators can be used for training the
candidates in a way that can be grasped in a short span of time with better
understanding. Creation of training modules using computer graphics is simple
and very useful.
Visualization:
Today the need of visualize things have increased drastically, the need of
visualization can be seen in many advance technologies , data visualization
helps in finding insights of the data , to check and study the behavior of
processes around us we need appropriate visualization which can be achieved
through proper usage of computer graphics
Image Processing:
Various kinds of photographs or images require editing in order to be used in
different places. Processing of existing images into refined ones for better
interpretation is one of the many applications of computer graphics.
Machine Drawing:
Computer graphics is very frequently used for designing, modifying and creation
of various parts of machine and the whole machine itself, the main reason
behind using computer graphics for this purpose is the precision and clarity we
get from such drawing is ultimate and extremely desired for the safe
manufacturing of machine using these drawings.
Input Devices:
The Input Devices are the hardware that is used to transfer transfers input to the
computer. The data can be in the form of text, graphics, sound, and text. Output device
display data from the memory of the computer. Output can be text, numeric data, line,
polygon, and other objects.
Keyboard:
The most commonly used input device is a keyboard. The data is entered by pressing
the set of keys. All keys are labeled. A keyboard with 101 keys is called a QWERTY
keyboard.
The keyboard has alphabetic as well as numeric keys. Some special keys are also
available.
1. Numeric Keys: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
7. Numeric Keyboard: It is on the right-hand side of the keyboard and used for
fast entry of numeric data.
Function of Keyboard:
1. Alphanumeric Keyboards are used in CAD. (Computer Aided Drafting)
2. Keyboards are available with special features line screen co-ordinates entry,
Menu selection or graphics functions, etc.
3. Special purpose keyboards are available having buttons, dials, and switches.
Dials are used to enter scalar values. Dials also enter real numbers. Buttons and
switches are used to enter predefined function values.
Advantage:
1. Suitable for entering numeric data.
2. Function keys are a fast and effective method of using commands, with fewer
errors.
Disadvantage:
1. Keyboard is not suitable for graphics input.
Mouse:
A Mouse is a pointing device and used to position the pointer on the screen. It is a
small palm size box. There are two or three depression switches on the top. The
movement of the mouse along the x-axis helps in the horizontal movement of the
cursor and the movement along the y-axis helps in the vertical movement of the cursor
on the screen. The mouse cannot be used to enter text. Therefore, they are used in
conjunction with a keyboard.
Advantage:
1. Easy to use
Advantage:
1. Trackball is stationary, so it does not require much space to use it.
2. Compact Size
Spaceball:
It is similar to trackball, but it can move in six directions where trackball can move in
two directions only. The movement is recorded by the strain gauge. Strain gauge is
applied with pressure. It can be pushed and pulled in various directions. The ball has a
diameter around 7.5 cm. The ball is mounted in the base using rollers. One-third of the
ball is an inside box, the rest is outside.
Applications:
1. It is used for three-dimensional positioning of the object.
Joystick:
A Joystick is also a pointing device which is used to change cursor position on a
monitor screen. Joystick is a stick having a spherical ball as its both lower and
upper ends as shown in fig. The lower spherical ball moves in a socket. The
joystick can be changed in all four directions. The function of a joystick is similar
to that of the mouse. It is mainly used in Computer Aided Designing (CAD) and
playing computer games.
Light Pen:
Light Pen (similar to the pen) is a pointing device which is used to select a displayed
menu item or draw pictures on the monitor screen. It consists of a photocell and an
optical system placed in a small tube. When its tip is moved over the monitor screen,
and pen button is pressed, its photocell sensing element detects the screen location
and sends the corresponding signals to the CPU.
Uses:
1. Light Pens can be used as input coordinate positions by providing necessary
arrangements.
When the wave signals are interrupted by some contact with the screen, that located is
recorded. Touch screens have long been used in military applications.
Output Devices
It is an electromechanical device, which accepts data from a computer and translates
them into form understand by users.
Printers:
Printer is the most important output device, which is used to print data on paper.
1. Impact Printers: The printers that print the characters by striking against the
ribbon and onto the papers are known as Impact Printers.
1. Character Printers
2. Line Printers
2. Non-Impact Printers: The printers that print the characters without striking
against the ribbon and onto the papers are called Non-Impact Printers. These printers
print a complete page at a time, therefore, also known as Page Printers.
1. Laser Printers
2. Inkjet Printers
Advantage:
1. Dot Matrix Printers prints output as dots, so it can print any shape of the
character. This allows the printer to print special character, charts, graphs, etc.
2. Dot Matrix Printers come under the category of impact printers. The printing is
done when the hammer pin strikes the inked ribbon. The impressions are printed
on paper. By placing multiple copies of carbon, multiple copies of output can be
produced.
Advantage:
1. More reliable than DMPs
2. Better Quality
Disadvantage:
1. Slower than DMPs
Drum Printers:
These are line printers, which prints one line at a time. It consists of a drum. The shape
of the drum is cylindrical. The drum is solid and has characters embossed on it in the
form of vertical bands. The characters are in circular form. Each band consists of some
characters. Each line on drum consists of 132 characters. Because there are 96 lines so
total characters are (132 * 95) = 12, 672.
Chain Printers:
These are called as line printers. These are used to print one line at a line. Basically,
chain consists of links. Each link contains one character. Printers can follow any
character set style, i.e., 48, 64 or 96 characters. Printer consists of a number of
hammers also.
Advantages:
1. Chain or Band if damaged can be changed easily.
Disadvantages:
1. It cannot print charts and graphs.
Non-Impact Printers:
Inkjet Printers:
These printers use a special link called electrostatic ink. The printer head has a special
nozzle. Nozzle drops ink on paper. Head contains up to 64 nozzles. The ink dropped is
deflected by the electrostatic plate. The plate is fixed outside the nozzle. The deflected
ink settles on paper.
Advantages:
1. These produce high quality of output as compared to the dot matrix.
Disadvantages:
Laser Printers:
These are non-impact page printers. They use laser lights to produces the dots needed
to form the characters to be printed on a page & hence the name laser printers.
Step2: The output device has a drum which is cleared & is given a positive electric
charge. To print a page the modulated laser beam passing from the laser scans back &
forth the surface of the drum. The positive electric charge on the drum is stored on just
those parts of the drum surface which are exposed to the laser beam create the
difference in electric which charges on the exposed drum surface.
Step3: The laser exposed parts of the drum attract an ink powder known as toner.
Step5: The ink particles are permanently fixed to the paper by using either heat or
pressure technique.
Step6: The drum rotates back to the cleaner where a rubber blade cleans off the
excess ink & prepares the drum to print the next page.
Bresenham's Line Algorithm
This algorithm is used for scan converting a line. It was developed by Bresenham. It is
an efficient method because it involves only integer addition, subtractions, and
multiplication operations. These operations can be performed very rapidly so lines can
be generated quickly.
In this method, next pixel selected is that one who has the least distance from true line.
Assume a pixel P1'(x1',y1'),then select subsequent pixels as we work our may to the
night, one pixel position at a time in the horizontal direction toward P 2'(x2',y2').
The line is best approximated by those pixels that fall the least distance from the path
between P1',P2'.
To chooses the next one between the bottom pixel S and top pixel T.
If S is chosen
We have xi+1=xi+1 and yi+1=yi
If T is chosen
We have xi+1=xi+1 and yi+1=yi+1
This difference is
s-t = (y-yi)-[(yi+1)-y]
= 2y - 2yi -1
We can write the decision variable di+1 for the next slip on
di+1=2△y.xi+1-2△x.yi+1+c
di+1-di=2△y.(xi+1-xi)- 2△x(yi+1-yi)
Special Cases
Finally, we calculate d1
d1=△x[2m(x1+1)+2b-2y1-1]
d1=△x[2(mx1+b-y1)+2m-1]
Advantage:
1. It involves only integer arithmetic, so it is simple.
3. It can be implemented using hardware because it does not use multiplication and
division.
Disadvantage:
1. This algorithm is meant for basic line drawing only Initializing is not a part of
Bresenham's line algorithm. So to draw smooth lines, you should want to look into a
different algorithm.
Bresenham's Line Algorithm:
Step1: Start Algorithm
Step5: Consider (x, y) as starting point and x endas maximum possible value of x.
If dx < 0
Then x = x2
y = y2
xend=x1
If dx > 0
Then x = x1
y = y1
xend=x2
Step9: Increment x = x + 1
Step11: Go to step 7
Translation
It is the movement of an object from one position to another position. Translation is
done using translation vectors. There are three vectors in 3D instead of two. These
vectors are in x, y, and z directions. Translation in the x-direction is represented using
Tx. The translation is y-direction is represented using Ty. The translation in the z-
direction is represented using Tz.
x1=x+ Tx
y1=y+Ty
z1=z+ Tz
= [5+0+0+30+6+0+30+0+7+20+0+0+1] = [8991]
x becomes x1=8
y becomes y1=9
z becomes z1=9
Scaling
Scaling is used to change the size of an object. The size can be increased or decreased.
The scaling three factors are required Sx Sy and Sz.
In figure (a) point (a, b, c) is shown, and object whose scaling is to done also shown in
steps in fig (b), fig (c) and fig (d).
Line Clipping:
It is performed by using the line clipping algorithm. The line clipping algorithms are:
1. Visible
2. Not Visible
3. Clipping Case
1. Visible: If a line lies within the window, i.e., both endpoints of the line lies within
the window. A line is visible and will be displayed as it is.
2. Not Visible: If a line lies outside the window it will be invisible and rejected. Such
lines will not display. If any one of the following inequalities is satisfied, then the line is
considered invisible. Let A (x1,y2) and B (x2,y2) are endpoints of line.
3. Clipping Case: If the line is neither visible case nor invisible case. It is considered to
be clipped case. First of all, the category of a line is found based on nine regions given
below. All nine regions are assigned codes. Each code is of 4 bits. If both endpoints of
the line have end bits zero, then the line is considered to be visible.
The center area is having the code, 0000, i.e., region 5 is considered a rectangle
window.
Step2:
Step3:
Step4:
(a) If bit 1 is "1" line intersects with left boundary of rectangle window
y3=y1+m(x-X1)
where X = Xwmin
where Xwminis the minimum value of X co-ordinate of window