This action might not be possible to undo. Are you sure you want to continue?
COMPUTER GRAPHICS
SYLLABUS
CHAPTER 1 INTRODUCTION → What is Graphics
Elements of a Graphics work station.
Video display devices – Random Scan System & Raster Scan System, Input devices –
Graphics Software, coordinate representation, fundamental problems in Geometry.
CHAPTER 2 ALGORITHMS → Line drawing algorithm, DTA algorithm, Presentian’s
algorithm, frame buffers, Circle & ellipse generating algo, midpoint circle alg., midpoint
ellipse algo, Polynomial & spline curves – inside, outside text, scan, line, file of curved
boundary areas, Boundary fill algo, flood fill algo, characters generation attributes of
lines, curves, filling character, etc.
CHAPTER 3 GRAPHICS PRIMITIVES
structure, display file algorithms.
The display file interpretes, display file
→
CHAPTER 4 ATTRIBUTES OF OUTPUT PRIMITIVES → Line attributes colour
attributes, file attributes and character attributes.
CHAPTER 5 GEOMETRIC TRANSFORMATION → Matrices, scaling transformations,
(sine & cos rotation), homogeneous rotation & translation, Rotation about on arbitrary
point, inverse transformation.
CHAPTER 6 2D VIEWING → Viewing pipeline, viewing coordinates reference frame,
window to view part coordinate transformation, 2D viewing function, clipping operations,
port clipping, line dipping, Sutherland / Cohens line clipping algo, polygon clipping algo,
Sutherland/Hodgeman polygon clipping algorithm.
CHAPTER 7 3D CONCEPTS → 3D Display methods, parallel projection, perspective
projection, visible line and surface identification, Bergier Curves & V spline curves.
CHAPTER 8 VISIBILITY Z BUFFER ALGORITHM
CHAPTER 9 Computer Animations, design of animation sequence, Raster animations,
morphing motion specification, kinematics & dynamics.
1
* INTRODUCTION TO COMPUTER GRAPHICS *
INTRODUCTION What is Graphics?
Elements of a Graphics work station.
Video display devices – Random Scan System & Raster Scan System, Input devices –
Graphics Software, coordinate representation, fundamental problems in Geometry.
Computer Graphics
Computer Graphics is the pictorial representation of information using a computer
program.
In Computer Graphics, pictures as graphical subjects are represented as a collection of
discrete picture element called pixels.
Pixel is smallest addressable screen element.
Pixel Column
P
1
& P
2
are represented as one pixel (4, 3)
The process of determining the appropriate pixels for representing pictures or object
is Rasterization & the process of representing continuous pictures as graphical object as
a collection of discrete pixel is called Scan Conversion.
Applications:
Some of the areas of applications of computer graphics is CAD (Computer Aided
Design). This is issued by civil, mechanical, algbrical & electronic engineers to build a
model of building, bridges, PCB circuit, etc.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
They can also be used for developing a model of bridge & various effect and stimulate
the situation in Developing a model of a bridge and testing it over a simulator for
earthquake resistance.
Medical Imaging – It can be used to train new doctors on understanding and
experimenting surgery.
It is used in molecular biology to study the biological model in genes.
CATHODE RAY TUBE (CRT)
Simplified representation of CRT:
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
BASIC OPERATION
A beam of electrons (i.e. cathode rays) is emitted by the electron gun, it passes
through focusing and deflection systems that direct the beam towards the specified
position on the phosphor screen. The phosphor then emits a small spot of light at every
position contacted by the electron beam. Since light emitted by the phosphor fades very
quickly some method is needed for maintaining the screen picture. One of the simplest
way to maintain pictures on the screen is to redraw the image rapidly. This type of display
is called Refresh CRT.
Primary components of CRT are as follows:
1 HEATER ELEMENT AND CATHODE
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Heat is supplied to the cathode by passing current through heater element. Cathode
is cylindrical metallic structure which is rich in electrons. On heating the electrons are
released from cathode surface.
2 CONTROL GRID
It is the next element which follows cathode. It almost covers cathode leaving small
opening for electrons to come out. Intensity of the electron beam is controlled by setting
voltage levels on the control grid. A high negative cottage applied to the control grid will
shut off the beam by repelling electrons and stopping them from passing through the
small hole at the end of control grid structure. A smaller negative voltage on the control
grid will simply decrease the number of electrons passing through. Thus we can control
the brightness of a display by varying the voltage on the control grid.
3 ACCELERATING ANODE
They are positively charged anodes who accelerate the electrons towards phosphor
screen.
4 FOCUSING & DEFLECTION COILS
They are together needed to force the electron beam to converge into a small spot
as it strikes the screen otherwise the electrons would repel each other and the beam
would spread out as it approaches the screen. Electrostatic focusing is commonly used in
television and computer graphics monitor.
5 PHOSPHOR COATING
When the accelerating electron beam (collides) is incident on the phosphor cooling,
a part of Kinetic Energy is converted into light and heat. When the electrons in the beam
collide with the phosphor coating they are stopped and their kinetic energy is absorbed
by the phosphor.
 There are two techniques for producing images on the CRT screen
1 Vector Scan / Random scan Display
2 Raster Scan display
1 VECTOR / RANDOM SCAN DISPLAY
Vector scan display directly traces out only the desired lines on the
CRT tube i.e. a CRT has the electron beam directed only to the
parts of the screen where a picture is to be drawn. Random scan
monitors draw a picture one line at a time and for this reason are
also known as Vector Scan Displays.
A
B
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
If we want a line connecting point A with B on the vector graphics display, we simply drive
the beam deflection circuiting, which will cause the beam to go directly from point A to B.
If we want to move the beam from point A to point B without showing a line between
points, we can blank the beam as we move it.
INTERNATIONAL OPERATION
An application program along with graphics package is present in the system
memory. The graphic commands is the program and translated by the graphics package
and stored in the display file. In other records the file used to store the commands
necessary for drawing the line segments is called the Display file. The program which
converts these commands into actual picture is called the Display file Interpreter. It is an
interface between the graphics representation in the display file and display device. The
display processor is connected to the display device, processes and manages the display
process.
The commands present in the display file contains two fields, an operation code (opcode)
and operands. Opcode identifies the commands such as line draw, move cursors, etc
and the operands provide the coordinate of a point to process the commands.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
One of the way to store opcode and operands of series of commands is to use to
separate arrays, one for opcode, one for xcoordinate and one for ycoordinate of the
operand. It is also necessary to assign meanings to the possible opcodes before we can
proceed to interpret them.
e.g. COMMAND OPCODE
MOVE 1
LINE 2
The figure below shows how these commands are interpreted and plotted.
Command 1: 1, 30, 30
Moves the current cursor
position to point (30, 30) (30
0
, 30)
(50, 80)
Command 2: 2, 50, 80
Draws line between
point (30, 30) & (50, 80)
(30, 30)
(50, 80)
Command 3: 2, 70, 30
Draws line between
points (70, 30) & (50, 80)
(30,30) (70,30)
(50,80)
Command 4” 1, 40, 55
It makes current cursor position to
point (40, 55)
(30,30) (30,30)
(50,80)
Command 5: 2. 60, 55
It draws the line between point (60, 55) (40,50) (60,55)
and current cursor
position (40, 55)
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
(30,30) (70,30)
RASTER SCAN DISPLAY
This is the most common method of drawing images on the
CRT screen. In this method. Horizontal and vertical
deflection signals are generated to move the beam all over
the screen in a pattern as shown in figure i.e. the electron
beam is swept across the screen one row at a time from top
to bottom.
Here the beam is swept back and forth from left to right
across the screen. When the beam is moved from left to
right it is ON. The beam is OFF when it moves from right to
left and is called as Horizontal Retrace and is shown by dotted lines.
When the beam reaches the bottom of the screen it is turned off and is rapidly retraced
back to the top to start again. This is called the Vertical Retrace. In the Raster Scan
display the screen image is maintained by repeating scanning of the same image. The
process is shown as Refreshing of screen.
INTERNAL OPERATION
Fig ÷ PROCESS – RASTER SCAN SYSTEM
Picture definition is stored in a memory area called Refresh buffer or Frame Buffer for
which a fined area of the system memory is kept reserved. The frame buffer holds the set
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
of intensity values for all the screen points. Stored intensity values are then retrieved from
the refresh buffer and displayed on the screen one row at a time. Video controller has
direct access to memory locations in the frame buffer. It is responsible for retrieving data
from the frame buffer and passing it to the display device.
Frame buffer maps the screen into cartesian coordinates. Generally, the screen co
ordinates are taken as positive (x, y) plane. Hence the screen is continuously refreshed
by scanning from maximum value of ycoordinate down to y = 0.
Distinguish between Raster & Random Scan
RASTER SCAN DISPLAY RANDOM SCAN DISPLAY
i) It draws the image by i) It draws the image by directing the electron
scanning one row at a time beam directly to the part of the screen
where the image is to be drawn.
ii) They generally have resolution ii) They have higher resolution than Raster
limited to pixel size. Scan System
iii) Lines are jaggered and curves iii) Line plots are straight and curves
are less smoother are smooth.
iv) They are more suited to geometric iv) They are more suited to line
area drawing applications e.g. drawing application e.g. CRO’s
monitors, Tele vision , pen plotter.
 COLOUR DISPLAYS
There are 2 methods for producing colour displays.
A. Beam Penetration technique
B. Shadow – Mask technique
BEAM PENETRATION TECHNIQUE
This technique is used in Random Scan Monitors. In this technique, the inside of
CRT is coated with two layers of phosphor, usually red & green. The displayed colour
depends on how far the electron beam penetrates into the phosphor layers. The outer
layer is of red phosphor and inner layer is of green phosphor. A beam of slow electrons
excites only the outer red layer. A beam of fast electrons penetrates the outer red layer
and excites the inner green layer. At intermediate beam speeds, combination of red and
green light are emitted and two additional colours orange and yellow are displayed. The
beam acceleration voltage controls the speed of the electrons and hence the screen
colour at any point on the screen.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
SHADOW MASK TECHNIQUE
The shadow mask technique produces a much wider range of colours than the
beam penetration technique. Hence this technique is commonly used in raster scan
displays including colour T.V.
In shadow mask technique, the CRT screen has three phosphor colour dots at each pixel
position. One phosphor dot emitts red light, another emits a green light and the third one
emits a blue light. The CRT has three electron guns one for each dot, a shadow mask
grid just behind the phosphor coated screen.
Fig ÷ SHADOW MASK TECHNIQUE
The shadow mask grid consists of series of holes aligned with the phosphor dot patterns.
As shown in figure, the three electron beams are deflected and focused as a group onto
the shadow mask and when they pass through a hole onto a shadow mask they excite a
dot triangle. A dot triangle consists of 3 small phosphor dots of red, green and blue
colour. These phosphor dots are arranged so that each electron beam can activate only
its corresponding colour dot when it passes through the shadow mask. A dot triangle
when activated appears as a small dot on the screen which has colour combination of
three small dots in the dot triangle. By varying the intensity of the three electron beams
we can obtain different colours in the shadow mask CRT.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
* INPUT DEVICES *
Following are the commonly used input devices
1 Keyboard
2 Mouse
3 Scanner
4 Trackball / Spaceball
5 Joystick
6 Digitizer / Graphical tablet
1 KEYBOARD
Keyboard is the primary input device for any graphics system. It is used for entering
text and numbers. Keyboards are available in various sizes, shapes & styles. The
standard keyboard consists of
1 Alphanumeric keys
2 Function keys
3 Modifier keys
4 Cursor Movement keys
5 Numeric Keypad
Fig ÷ KEYBOARD PROCESS
When we press a key on the keyboard, the keyboard controller places a code
corresponding to the key pressed, in a part of its memory called keyboard buffer. This
code is called the scan code. The keyboard controller informs the CPU of the computer
about the key pressed with the help of interrept signals. The CPU then reads the scan
code from the Keyboard Buffer.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
2 MOUSE ÷ A mouse is a palm sized box used to position the screen cursor. It consists
of a ball on the bottom connected to wheels to provide the amount and direction of
movement. One, two or three buttons are usually included on the top of the mouse for
signaling the execution of same operation. Nowadays mouse consists of one more
wheel on top to scroll the screen pages.
3 TRACL BALL & SPACEBALL
Fig ÷ TRACKBALL
A trackball is a ball that can be rotated with the finger or palm of the hand to produce the
screen cursor movement. Potentiometers attached to the ball measure the amount and
direction of rotation.
While the trackball is used for 2D positioning, the spaceball is used for 3D positioning &
selection of operation in virtual reality system unlike the trackball the spaceball does not
actually move. It consists of strain gauges which measures the amount of pressure
applied to the spaceball to provide input for spatial positioning & orientation of the ball is
pushed a pulled in various directions.
4 SCANNER
Scanner have become an important part of the home, office over the last few years. It is a
device which can be used to store drawings, graphics, photos as text available in the
printed form for computer processing.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Fig ÷ PHOTO SCANNER
As shown in the fig the photograph is mounted on a rotating drum. A finely collimated
light beam is directed at the photo, and the amount of light reflected is measured by a
photocell. As the drum rotates the light source slowly moves from one end to the other,
thus doing a raster scan of the inter photograph.
5 JOYSTICK
Fig (A) ÷ JOYSTICK
(B) ÷ CIRCUIT DETAILS
A joystick has a small vertical lever mounted on the base and used to steer the
screen cursor around. It consists of two potentiometers attached to a single liver. Moving
the liver changes the settings on the potentiometer. The left or right movement is
indicated by other one potentiometer & the forward or backward movement is indicated
by other potentiometer. Thus with a joystick box x & y coordinate positions can be
simultaneously altered by the motion of a single lever.
Some joysticks may return to this zero (centre) positions when released. Joysticks
are inexpressive and quiet commonly used where only rough positioning is needed.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
6 DIGITIZER / GRAPHICAL TABLET
For applications such as tracing we need a device called a Digitizer or Graphical
Tablet. It consists of a flat surface, ranging in size from about 6 x 6 inches upto 48 to 72
inches or more, which can direct the position of a movable styles.
In this arrangement a grid of wires of ¼ to ½ inch centers is embedded in the tablet
surface. Electromagnetic signals generated by electrical pulses applied in sequence to
the wires in the grid induce an electrical signal in a wire cod in the styles. The strength of
the signal induced by each pulse is used to determine the position of the styles.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
2
LINE DRAWING ALGORITHM
ALGORITHMS ÷ Line drawing algorithm, DTA algorithm, Presentian’s algorithm, frame
buffers, Circle & ellipse generating algo, midpoint circle alg., midpoint ellipse algo,
Polynomial & spline curves – inside, outside text, scan, line, file of curved boundary
areas, Boundary fill algo, flood fill algo, characters generation attributes of lines, curves,
filling character, etc.
DDA ALGORITHM [DIGITAL DIFFERENTIAL ALGORITHM]
The slope of a straight line is given as
The above differential Eqn. Can be written as
Once the intervals are known, the values for rent x & y can be obtained as follows
x
i+1
= x
i
+ Ax
The eqns 3 & 4 are called as the recursive eqns for finding out the successive values of x
& y along a required line. Such a way of rasterising a line is called Digital Differential
Algorithm.
1
1 2
1 2
÷
÷
÷
=
A
A
=
x x
y y
n
y
m
2 &
1 2
1 2
1 2
1 2
÷ A
÷
÷
= A
A
÷
÷
= A
y
y y
x x
n
x
x x
y y
y
4 &
3
1 2
1 2
1
1 2
1 2
1
÷ A
÷
÷
+ =
÷ A
÷
÷
+ =
+
+
x
x x
y y
y y
y
y y
x x
x x
i i
i i
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
If  Ax  >  Ay , then Ax = 1
else Ay = 1
If, Ax = 1, then
If, Ay = 1, then
DDA Line ALGORITHM
Step 1 Read the line end points (x
1
, y
1
) & (x
2
, y
2
) such that they are not equal
2 Ax =  x
2
– x
1
 &
Ay =  y
2
– y
1

3 If Ax > Ay, then length = Ax, else
length = Ay
[This makes either Ax & Ay = 1 because length is either absolute value of (x
2
– x
1
) or
absolute value of (y
2
– y
1
). Therefore the incremental value for either x or y is 1]
5 x = x
1
+ sign (Ax) & y = y
1
+ sign (Ay)
[The sign function makes the algorithm work is all the quadrants]
6 i = 1 (counter)
while (i s length)
{
Plot (Integer (x), Integer (y))
x = x + Ax
y = y + Ay
i = i + 1
1
1
1 2
1 2
1
+ =
÷
÷
+ =
+
+
i i
i i
x x
x x
y y
y y
1
1
1 2
1 2
1
+ =
÷
÷
+ =
+
+
i i
i i
y y
y y
x x
x x
Length
y y
y
Length
x x
x
1 2 1 2
&
÷
= A
÷
= A
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
}
7 Stop.
Q. Consider the line from (0, 0) to (4, 6). Use the DDA algorithm to rasterize the line.
Step 1. x
1
= 0, y
1
= 0, x
2
= 4, y
2
= 6
2. Ax = 4 – 0 = 4, Ay = 6 – 0 = 6
3. Length = Ay = y
2
– y
1
 = 6
5. x = x1 + Sign (Ax) 6. y = y1 + Sign (Ay)
= 0 + 0.67 = 0 + 1
= 0.67 = 1
i Plot x t
0.67 1
1 (1, 1) (1.34) 2
2 (1, 2) 2.01 3
3 (2, 3) 2.68 4
4 (3, 4) 3.35 5
5 (3, 5) 4.02 6
6 (4, 6) 4.69 7
1
6
6
,
6
4
4
1 2 1 2
= =
÷
= A =
÷
= A
Length
y y
y
Length
x x
x
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Q. Consider a line from (0, 0) to (6, 6) use the DDA algorithm to rasterize.
1. x
1
= 0 x
2
= 6
y
1
= 0 y
2
= 6
2. Ax =  6 – 0  = 6
Ay =  6 – 0  = 6
3. length = Ax =  x
2
– x
1
 = 6
5. x = x
1
+ Sign (Ax), y = y
1
+ Sign (Ay)
= 0 + 1 = 0 + 1
= 1 = 1
i Plot x y
0 1 1
1 (1, 1) 2 2
2 (2, 2) 3 3
3 (3, 3) 4 4
4 (4, 4) 5 5
5 (5, 5) 6 6
1
6
6
1
6
6
. 4
1 2
1 2
= =
÷
= A
= =
÷
= A
Length
y y
y
Length
x x
x
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
6 (6, 6)
BRESENHAM’S LINE DRAWING ALGORITHM
Bresenham’s Algorithm uses only integer addition, subtraction and multiplication by
2 which the computer can perform rapidly. Hence, it is an efficient method for scan
converting the straight line.
The basic principle is to select an optimum raster location to present a straight line.
The algorithm always increments either x or y by one unit depending on the slope of the
line. The increment in the other variable is determined by examining the distance
between the actual line location and the nearest pixel. This distance is called the
Decision Variable or error represented as ‘e’. If e > 0, it implies that the pixel above the
line is closes to the true value. if e s 0, it implies the pixel below the line is closer to the
true value.
Thus by checking the sign of the error term, it is possible to determine the better
pixel to represent the line path.
e = 2 * Ay  Ax, where Ay = y
2
– y
1
Ax = x
2
– x
1
According to the value of e, the following actions are taken,
while (e > 0)
{
y = y + 1
e = e – 2 * Ax
}
x = x + 1
e = e + 2 * Ay
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
ALGORITHM
STEP 1. Read the line end points (x
1
, y
1
) & (x
2
, y
2
) such that they are not equal.
2. Ax = x
2
– x
1
& /
Ay = y
2
– y
1
3. Initialize starting point as
x = x
1
& y = y
1
4. e = 2 * Ay  Ax
[Initialize value of decesion variables or error]
5. Initialize counter i = 1
6. Plot (x, y)
7. while (e > 0)
{
y = y + 1
e = e2 * Ax
y
x = x + 1
e = e + 2 * Ay
8. i = i + 1
9. If (i s Ax) go to step 6
10. Stop.
Ex 1. Consider a line from (5, 5) to (13, 9). Use the B. L. DAL to rasterize the line.
1. x
1
= 5 x
2
= 13
y
1
= 5 y
2
= 9
2. Ax = x
2
– x
1
 = 13 – 5 = 8
Ay = y
2
– y
1
 = 9 – 5 = 4
3. x = 5, y = 5
4. e = 2 * Ay  Ax
= 2 * 4 – 8
= 0
5. i = 1
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
i Plot x y e
5 5 0
1 (5, 5) 6 6 8
2 (6, 6) 7 6 0
3 (7, 6) 8 7 8
4 (8, 7) 9 7 0
5 (9, 7) 10 8 8
6 (10, 8) 11 8 0
7 (11, 8) 12 9 8
8 (12, 9) 13 9
Ex. 2. Consider a line from (2, 5) to (10, 10). Apply Bresenham’s line drawing algorithm to
plot the line.
1. x
1
= 2 x
2
= 10
y
1
= 5 y
2
= 10
2. Ax = x
2
– x
1
 = 10 – 2 = 8
Ay = y
2
– y
1
 = 10 – 5 = 5
3. x = 2
y = 5
4. e = 2 * Ay  Ax = 2 x 5 – 8 = 2
e = 2
5. i = 1
i Plot x y e
2 5 2
1 (2, 5) 3 6 4
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
2 (3, 6) 4 6 6
3 (4, 6) 5 7 4
4 (5, 7) 6 8 2
5 (6, 7) 7 8 +8
6 (7, 8) 8 9 2
7 (8, 9) 9 10 4
8 (9, 10) 10 10
CIRCLE GENERATING ALGORITHM
A Circle is a symmetric figure. It has 8way symmetry. Thus a circle generating algorithm
can take advantage of circle symmetry to plot 8 points by calculating the coordinate of
any one point.
e.g. If point A is calculated with circle generating algorithm then 7 more points can be
drawn by just reflection.
MIDPOINT CIRCLE GENERATING ALGORITHM
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
The Midpoint Circle Generating algorithm uses 8way of symmetry of the circle
generated. If plots 1/8
th
part of a circle is from 90° to 45°. So the xcoordinate who is in
+ve direction & ycoordinate who is in –ve direction. We take unique steps in x direction
and make use of decision parameters to determine which of the 2 possible ypositions
are closer to the circular path of each step. The 2 possible y positions are y
i
and y
i1
and
at same position x
i
and x
i+1
. We have to determine whether the pixel at position (x
i+1
, y
i
)
as (x
i+1
, y
i1
) is close to the circle. So for that purpose the decision parameter is used
which uses the circle function.
Parde (x, y) = x
2
+ y
2
– r
2
The decision parameter
di = Parde (x
i
+ 1, y
i
– ½)
= (x
i
+ 1)
2
+ (y
i
– ½)
2
– r
2
÷ 1
If di < 0, the midpoint is inside the circle and the pixel on the scan line yi is closer to the
circle boundary.
If di > 0, then the midpoint is outside or on the circle boundary & yi1 is closer to the circle
boundary. The incrementry calculation can be determined to obtain the successive
decision parameter.
d
i+1
= (x
i+1
+ 1)
2
+ (y
i+1
– ½)
2
– r
2
= (x
i+1
)
2
+ 2x
i+1
+ 1 + (y
i+1
)
2
– y
i+1
+ ¼  r
2
d
i+1
= (x
i+1
)
2
+ 1 + 2x
i+1
+ (y
i+1
)
2
– y
i+1
+ ¼  r
2
From 1, put (x
i+1
)
2
– r
2
= d
i
– (y
i
– ½)
2
d
i+1
= d
i
–(y
i
– ½)
2
+ 1 + 2x
i+1
+ (y
i+1
)
2
– y
i+1
+ ¼
= d
i
– y
i
2
– ¼ + y
i
+ 1 + 2x
i+1
+ (y
i+1
)
2
– y
i+1
+ ¼
= d
i
– [(y
i
)
2
– (y
i+1
)
2
] – [y
i+1
– y
i
] + 1 + 2x
i+1
d
i+1
= d
i
[(y
i
+1)
2
– (y
i
)
2
] – [y
i+1
– y
i
] + 1 + 2x
i+1
where y
i+1
is either y
i
or y
i1
1) If d
i
< 0 then y
i+1
= y
i
d
i+1
= d
i
+ 2(x
i+1
) + 1
2) If d
i
> 0 then y
i+I
= y
i1
d
i+1
= d
i
+ [(y
i
1)
2
– (y
i
)
2
] – [y
i
–1 – y
i
] + 1 + 2x
i+1
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
d
i+1
= d
i
+ 2x
i+1
+ 1 + [(y
i
)
2
– 2y
i
+ 1 – (y
i
)
2
] – [y
i
– y
i
+ 1]
d
i+1
= d
i
+ 2x
i+1
+ 1 – 2y
i
Initial decision parameter at start position (x0, y0) = (0, r)
d
0
= Farde (0, r – ½)
= (0 + 1)
2
+ (r – ½)
2
– r
2
= 1 + r
2
– r + ¼  r
2
= 1 + ¼  r
= 5/4 – r
d0 = 1.25  r
ALGORITHM
Step 1. Read the radius r of the circle.
Step 2. Initialize the starting point x = 0 & y = r
Step 3. Calculate the initial value of the decision parameter as d
0
= 1.25 – r
Step 4. Do
{
Plot(x, y)
If (d < 0)
{
x = x + 1
y = y
d = d + 2x + 1
}
else
x = x + 1
y = y – 1
d = d + 2x – 2y + 1
}
}
while (x < y)
Step 5. Determine the symmetry points
Step 6. Stop.
ELLIPSE GENERATING ALGORITHM
Ellipse is an elongated circle with a major axis & a minor axis.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
ry
2
x
2
+ rx
2
y
2
= rx
2
ry
2
ry
2
x
2
+ rx
2
y
2
– rx
2
ry
2
= 0
Midpoint ellipse algorithm
The midpoint ellipse algorithm is applied throughout the first quadrant in two parts. We
process this quadrant by taking unit steps in x direction where the slope of the curve has
a magnitude less than 1, and taking unit step in the y direction where the slope has a
magnitude greater than 1.
We start at position (0, ry) and step clockwise along the elliptical path in the first quadrant
shifting from unit steps in x to unit steps in y when the slope becomes less than –1.
We define an ellipse function as ellipse (x, y) = ry
2
x
2
+rx
2
y
2
– rx
2
ry
2
which has the
following properties
The ellipse slope is calculated as
1
2
2
2
2
= +
ry
y
rx
x
seis Eqnofellip
¦
¹
¦
´
¦
>
=
<
ry ipsebounda outsideell y x
oundary anellipseb y x
y pseboundar insideelli y x
y x fellipse
) , ( 0
) , ( 0
) , ( 0
) , (
2
2
. 2
. 2 . 2
0 2 . 2 .
) ( ) ( ) (
2
2
2 2
2 2
2 2 2 2 2 2
2 2 2 2 2 2
÷
÷
=
÷ =
= +
= +
÷ +
yrx
ry x
dx
dy
ry x
dx
dy
rx y
x ry
dx
dy
y rx
ry rx
dx
d
x
dx
d
ry y
dx
dy
rx
ry rx x ry y rx
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Differentiating the eqn
Let the boundary between region 1 &2
We move out of region 1 whenever 2x.ry
2
> 2yrx
2
Region 1
The decision parameter at midpoint is
P
1
k
= fellipse (x
R
+ 1, y
R
– ½)
= ry
2
(x
R
+1)
2
+ rx
2
(y
K
1/2)
2
– rx
2
ry
2
÷ 3
If P1k < 0, the midpoint is inside the ellipse and the pixel of scan line yk is closer to
the ellipse boundary. Otherwise, the midposition outside or on the ellipse boundary, and
we select the pixel on the scan line yk1
at the next sampling position
2 2 2
2
2
. 2 .
. 2
. 2
1
1
rx y ry x
rx y
ry x
dx
dy
Slope
=
÷
= ÷
÷ = =
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
P
1
k+1
= fellipse (x
k+1
+ 1, y
k+1
– ½)
= ry
2
[(x
R+1
) + 1]
2
+ rx
2
[y
R+1
– ½]
2
– rx
2
ry
2
from
P
1
k+1
= ry
2
[(x
R
+1)
2
+ 2(x
R+1
) + 1] + rx
2
[(y
R+1
)
2
– (y
R+1
) + ¼] – rx
2
ry
2
P
1
k+1
= ry
2
(x
R
+1)
2
+ 2ry
2
(x
R
+1) + ry
2
+ rx
2
(y
R
+1)
2
– rx
2
(y
R
+1) + rx
2
– rx
2
ry
2
P
1
k+1
= P
1
k
– rx
2
(y
k
– ½)
2
+ 2ry
2
(x
R
+1) + ry
2
+ rx
2
(y
R+1
– ½)
2
From Eqn 3
P
1
k+1
= P
1
k
+ 2ry
2
(x
R
+1) + ry
2
+ rx
2
(y
R+1
– ½)
2
– rx
2
(yR – ½)
2
÷ 4
If P
1
k
< 0, y
k+1
= y
k
P
1
k+1
= P
1
k
+2ry
2
(x
R
+1) + ry
2
& If P
1
k
> 0, y
R
+ 1 = y
k
– 1
P
1
k+1
= P
1
k
+ 2ry
2
(x
R+1
) + ry
2
+ rx
2
[(y
R
– 1 – ½)
2
– (y
R
– ½)
2
]
P
1
k+1
= P
1
k
+ 2ry
2
(x
R
+1) + ry
2
+ rx
2
[(y
R
– 3/2)
2
– (y
R
– ½)
2
]
P
1
k+1
= P
1
k
+ 2ry
2
(x
k+1
) + ry
2
+ rx
2
(2 – 2y
R
)
P
1
k+1
= P
1
k
+ 2ry
2
(x
R
+1) + ry
2
– 2rx
2
(y
R
1)
In region 1, the value of decesion parameter is obtained by evaluating the ellipse function
at the start position (0, ry)
P
1
0
= fellipse (0+1, ry1/2)
P
1
0
= r
2
y + rx
2
(ry – ½)
2
– rx
2
ry
2
P
1
0
= r
2
y +r
2
xry + rx
2
/4
Region 2
Over region 2, we sample unit steps in negative y direction and the midpoint is now taken
between the horizontal pixels at each step. In this region the decision parameter is
evaluated as
P
2
k
= fellipse (x
R
+ ½, y
k
– 1)
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
P
2
k
= ry
2
(x
k
+ ½)
2
+ rx
2
(y
k
– 1)
2
– rx
2
ry
2
If P
2
k
> 0, the midpoint is outside the ellipse boundary and we select the pixel at position
x
R+1
. If P
2
k
< 0 then at the next sampling position
POLYLINE
ry rx y rx x ry P
y x fellipse P
y x ry rx yk rx rx P P
x ry y rx P P
ry rx y y rx x x ry P
ry rx y rx x ry P e i
k k
k k
k k
k k
R R R R
k
k R
k
2
0
2
2
0
2
0
2
0
0
2
2
1
2 2 2 2 2
2 2 2 2
1
2
2 2
1
2
1
2 2
1
2
1
2
2 2 2 2
2
2
1
2
) 1 (
2
1
1 ,
2
1
2
1
2
1
) 1 ( 2 2
) 1 ( ) 1 (
)] ( 2 1 ) [(
4
1
) 1 ( ) (
) 1 1 (
2
1
1 . .
÷ ÷ +

.

\

+ =

.

\

÷ + =

.

\

+ ÷

.

\

+ + + ÷ ÷ ÷ =
+ + ÷ ÷ =
÷ ÷ + +
+ + + =
÷ ÷ + +

.

\

+ + =
+
+
+ + +
+
+
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
A polyline is a chain of connected line segments. It is specified by giving the vertices P
0
,
P
1
, P
2
, & so on. The first vertex is called the initial or starting point & the last vertex is
called final or terminal point.
POLYGON
When starting point & the terminal point of any polyline is same i.e. when polyline is
closed then it is called as a polygon.
TYPES OF PLYGON
 The classification of polygons is based on where the line segment is joining any two
points within the polygon is going to lie.
 Types are – convex & concave polygon
1. CONVEX POLYGON
A convex polygon is a polygon in which the line segment joining any 2 points within the
polygon lies completely inside the polygon.
2. CONCAVE POLYGON
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
A Concave Polygon is a polygon in which the line segment joining any 2 points
within the polygon lies partially outside the polygon.
Inside – Outside or Odd Even Test
To show that a polygon is a solid object we need to set pixel inside the polygon as
well as on the boundary. One simple method to determine whether a point is inside a
polygon or not is to determine an inside outside test.
Construct the line segment between the point in question and a point known to be outside
the polygon. Now count the number of intersections of the line segments with the polygon
boundary. If there are odd number of intersections then the point is inside the polygon
otherwise it is outside the polygon. This method is also known as even off method of
determining the points inside the polygon.
POLYGON FILLING
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Filling in the polygon means highlighting all the pixels while lie inside the polygon
with any colour other than the background colour. There are 2 basic approaches to fill the
polygon.
1. Flood – Fill Method
2. Scan – Line Method
FLOOD FILL METHOD
 In this approach we start from a given seed point known to be inside the polygon and
highlight outwards from this point until we encounter the boundary pixels.
 This approach is called the flood fill because colour flows from the seed pixel until
reaching the polygon boundary like water flooding on the surface of a container.
 There are 2 methods for proceeding to the neighboring pixels.
1. 4 Connected
In this case, the pixelposition that are to the right, left, above and below. The current
pixel are tested.
2. 8 Connected
In this case, along with the 4 pixel positions used in the 4connected method, 4diagonal
pixels are also tested.
SCANLINE ALGORITHM
 The fig illustrates the scanline algorithm for filling of the polygon.
 For each scan line crossing the polygon, this algorithm locate the intersection points
of the scan line with the polygon edges.
 These intersection points are sorted from left to right, and the corresponding
positions between each intersection pair are set to the specified fill colour.
 The scanline algorithm first finds the largest & the smallest of y values of the polygon,
it then starts with the largest y value and works its way down, scanning from left to
right, in the manner of a Raster display.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 The important task in this algorithm is to find the intersection points of the scan line
with the polygon boundary.
 According to insideoutside tests, when the intersection points are even, they are
sorted from left to right the paired & pixels between the paired points are set to the fill
colour. But in some cases, intersection point is a vertex. When scan line intersects
polygon vertex, a special handling is required t find the exact intersection points.
 As shown in the figure above each scan line intersects the vertex of the polygon.
 For scan line 1, the other end points (B & D) of the two line segments of the polygon
lie on the same side of the scan line. Hence it is considered an even point i.e. they
are considered as 2 intersecting points.
 For scan line 2, the other end points D & F, of the two line segments of the polygon
lie on opposite side of the scan line, hence they are considered as a single
intersection point as odd point.
Raster Algorithms
2.1 Line Drawing Algorithms –
In computer graphics, complex objects are formed using graphics primitives. These
graphics primitives are pixel, line, curve, polygon, text, circle, ellipse etc. Let us start with
the drawing algorithms.
2.1.1 DDA (Digital Differential Analyzer) Algorithm –
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
The DDA is an algorithm for calculating the pixel positions along a line. This is done, by
taking 7 unit steps with one of the coordinates and calculating corresponding values for
other coordinated case1 If absolute value of the slope is less than or equal to 1, then x
coordinate is changed in unit steps and corresponding change in y is calculated.
The equation of the line is given as,
y = mx + h
Differentiating the above equation with respect to x we get,
dy/dx = m
dy = mdx
Since, x is changed in unit steps,
dx = 1 and dy = m
From the above equations, we can write,
x
1
+ 1 = x
1
+ 1
y
1
+ 1 = y
1
+m
Case2 If absolute value of slope is greater than 1, then y is changed in unit steps and
corresponding change in x is calculated.
Differentiating the equation of the line with respect to y we get,
dx = (1/m) dy
Since, y is changed in unit steps,
dy = 1 and dx = (1/m)
2.1 Prepared by Samir Lele
From the equations of dx and dy, we can write,
x
1+1
= x
1
+ 1/m
y
1+1
= y
1
+ 1
Thus, in both the cases, if we know (x
1
, y
1
), then we are in position to determine (x1+1,
y1+1). The process is started from the endpoints of the line and is stopped when
other endpoint reached. The above process can be written in steps as follows,
Algorithm:
1) Read both the end points as (x
1
, y
1
) and (x
2
, y
2
).
dy
dx
m = 1
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
2) Calculate chx and chy as,
chx ÷ x
2
 x
1
chy ÷ y
2
 y
1
3) If abs (chx) > abs (chy) Then steps ÷ abs (chx)
Else steps ÷ abs (chy)
4) Calculate x
inc
and yinc as,
x
inc
÷ chx / steps
y
inc
÷ chy / steps
5) Start with first endpoint and display it,
x ÷ x
1
y ÷ y
1
putpixel (x, y)
6) Repeat following, steps times.
a) Increment x as, x ÷ x + x
inc
b) Increment y as, y ÷ y + y
inc
c) Display the pixel, putpixel (x, y)
Disadvantatge – Since, DDA algorithm uses division operations, involves floating point
operations and hence requires more time.
2.1.2 Bresenham’s Line Drawing Algorithm –
This algorithm use only integer arithmetic and hence it is more efficient.
As shown in the diagram, say a point (4, 5) is drawn.
Now, we have to decide the next point in the line. It
can be (5, 5) or (5, 6). This is because, actual line is
passing through such a point, which can not be
represented on the screen. Hence, we have to select
nearer integer value.
Let us consider a line, with positive slope that is less
than or equal to 1. Therefore, x is changed in unit
steps. Let us assume that, a point (x
1
, y
1
) is drawn
and we have to decide the next point. We have two options, either (x
1
+ 1, y
1
) or (x
1
+ 1,
y
1
+ 1). One of these two points is selected, whichever is nearer to actual position.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
From this diagram, we can write following equations,
y = m (x
1
+ 1) + h
d
1
= y – y
1
d
1
= m (x
1
+ 1) + h – y
1
d
2
= (y
1
+ 1) – y
d
2
= y
1
+ 1 – m (x
1
+ 1) – h
The difference d1 – d2 is calculated as,
d
1
– d
2
= m (x
1
+ 1) + h – y
1
– y
1
– 1 + m (x
1
+ 1) + h
d
1
– d
2
= 2m (x
1
+ 1) – 2y
1
+ 2n1
Substitute m as Ay / Ax
d
1
– d
2
= (2Ay / Ax) (x
1
+ 1) – 2y
1
+ 2h1
Ax (d
1
– d
2
) = 2Ay (x
1
+ 1) – 2y
1
Ax+ (2h – 1) Ax
Let us call Ax (d
1
– d
2
) as P
1
.
P
1
= 2Ay (x
1
+ 1)  2Axy
1
+ (2h – 1) Ax  1
From the eqn. 1, we can calculate P
1
+ 1 as follows,
P
1+1
= 2Ay (x
1+1
+ 1)  2Axy
1+1
+ (2h1) Ax
P
1+1
= 2Ay (x
1
+ 2) – 2Axy
1+1
+ (2h1) Ax  2
The eqn. 2 – 1 gives,
P
1+1
= 2Ay (x
1
+ 2 – x
1
– 1)  2Axy
1+1
+ 2Axy
1
P
1+1
= P
1
+ 2Ay  2Ax (y
1+1
– y
1
)  3
If P
1
is negative, then d
1
< d
2
and hence y
1+1
= y
1
. By substituting this condition, in eqn 3
we get,
P
1+1
= P
1
+ 2Ay  4
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
If P1 is zero or positive then d1 > d2 and hence y1+1 = y1 + 1.
By substituting this condition in eqn 3 we get,
P
1+1
= P
1
+ 2Ay  2Ax  5
Thus, from eqn 4 and 5 we can calculate P1+1, if we know P1. In this case, P1 should be
known.
P
1
= 2Ay (x
1
+ 1) – 2y
1
Ax + (2h1) Ax
P
1
= 2Ay (x
1
+ 1) – 2y
1
Ax + (2h1) Ax
Let us substitute, h – y1 – mx1 in the above equation.
P
1
= 2Ay (x
1
+ 1) – 2Axy
1
+ (2y
1
– 2mx
1
– 1) Ax
Thus, we can summarize above calculations as,
P
1
= 2Ay  Ax
P
1+1
= P
1
+ 2Ay if P
1
< 0
P
1+1
= P
1
+ 2(Ay  Ax) if P
1
> 0
Similar equations can be obtained for the line whose absolute of the slope is greater than
1. In that case, y is changed in units steps and the corresponding change in x is
calculated. The equations in this case will be as follows,
P
1
= 2Ax  Ay
P
1+1
= P1 + 2Ax if P
1
< 0
P
1+1
= P
1
+ 2 (Ax  Ay) if P
1
> 0
All the six equations do not involve floating point calculations and hence it will be faster
than DDA line drawing algorithm.
The complete process can be written in steps as follows.
Algorithm
1) Read both the end points of a line as (x1, y1) and (x2, y2).
2) Calculate Ax and Ay as
Ax ÷ abs (x
2
– x
1
)
Ay ÷ abs (y
2
– y
1
)
3) Initialize the value of (x, y) as (x1, y1)
x ÷ x
1
y ÷ y
x y P
x yx xy xy y yx P
x x
x
y
y xy x y P
A ÷ A =
A ÷ A ÷ A + A ÷ A + A =
A ÷
A
A
÷ + A ÷ + A =
2
2 2 2 2 2
) 1 2 2 ( 2 ) 1 ( 2
1
1 1 1 1 1
1 1 1 1 1
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
4) Plot the pixel
putpixel (x, y)
5) Decide the increment value of x and y
If (x
1
< x
2
) Then x
inc
÷ 1 Else x
inc
÷ 1
If (y
1
< y
2
) The y
inc
÷ 1 Else y
inc
÷ 1
6) Decide whether change in x is greater or change in y is greater and change the
corresponding coordinate in unit steps and calculate other coordinate accordingly.
If (Ax > Ay) Then
Begin
a) Initializing the parameter
P ÷ 2Ay  Ax
b) While x < > x2 do
Begin
x ÷ x + x
inc
If P < 0
Then P ÷ P + 2Ay
Else
Begin
P ÷ P + 2 (Ay  Ax)
y ÷ y + y
inc
end
putpixel (x, y)
End
Else
Begin
a) Initialize the parameter as
P ÷ 2Ax  Ay
b) While y < > y2 do
Begin
Y ÷ y + yinc
If ( P < 0)
Then, P ÷ P + 2Ax
Else,
Begin
P ÷ P + 2 (Ax  Ay)
X ÷ x + xinc
end
putpixel (x, y)
end
end
Problem – Apply Bresenham’s line drawing algorithm to the end points,
(x
1
, y
1
) = (20, 20) and (x
2
, y
2
) = (12, 15)
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Ans –
Ax ÷ abs (12 – 20) ÷ 8, Ay ÷ abs (15 – 20) ÷ 5
Since x
1
< x
2
i.e. 20 < 12 is false, x
inc
÷ 1
Since y
1
< y
2
i.e. 20 < 15 is false, y
inc
÷ 1
Since Ax < Ay is true, then part of step 6 of the algorithm will come in picture. The
calculations can be done as shown below.
x
i
y
i
P
i
P
i+1
Plotted pixel
x
i+1
y
i+1
20 20
20 20 2 4 19 19
19 19 4 6 18 19
18 19 6 0 17 18
17 18 0 6 16 17
x
i
y
i
P
i
P
i+1
Plotted pixel
x
i+1
y
i+1
16 17 6 4 15 17
15 17 4 2 14 16
14 16 2 8 13 16
13 16 8 2 12 15
2.2 Circle Drawing Algorithms
There are two different types of algorithms to draw the circle.
2.1.1 Bresenham’s Circle Drawing Algorithm –
In the Bresenham’s circle algorithm, the process is similar to the drawing algorithm. The
parametric equations P
i
and P
i+1
are calculated in the same manner. Let us say that, a
point (x
i
, y
i
) is drawn. The next point to be drawn is to be decided. It can be either (x
i
+1,
y
i
) (x
i
+ 1, y
i
– 1).
The equation of the circle is x
2
+ y
2
= r
2
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
y
2
= r
2
– x
2
The circle drawing is started from a point (0, r) assuming (0, 0) as center of the circle.
From the diagram2, we can write,
d
1
= y
i
2
– y
2
and d
2
= y
2
– (y
i
– 1)
2
d
1
= y
i
2
(r
2
– x
2
) = y
i2
– (r
2
– (x
i
+ 1)
2
)  1 x = x
i
+ 1
d
1
= y
i
2
– (r
2
– (x
i
+1)
2
)
Similarly,
d
2
= y
2
– (y
i
– 1)
2
d
2
= (r
2
– x
2
) – (y
i
– 1)
2
d
2
= (r
2
– (x
i
+ 1)
2
) – (y
1
– 1)
2
 2 x = x
i
+ 1
The parameter P
i
is given as, P
i
= d
1
– d
2
P
i
= y
i
2
– (r
2
– (x
1
+ 1)
2
) – (r
2
– (x
i
+ 1)
2
– (y
i
– 1)
2
)
P
i
= y
i
2
+ r
2
+ (x
i
+ 1)
2
– r
2
+ (x
i
+1)
2
+ (y
i
– 1)
2
P
i
= 2 (x
i
+ 1)
2
+ y
i
2
+ (y
i
1)
2
– 2r
2
 1
From the equation we can write,
P
i+1
= 2(x
i+1
+ 1)
2
+ y
i+1
2
+ (y
i+1
– 1)
2
– 2r
2
P
i+1
= 2 (x
i
+1 + 1)
2
+ y
i+1
2
+ (y
i+1
– 1)
2
– 2r
2
P
i+1
= 2(x
i
+ 2)
2
+ y
i+1
2
+ (y
i+1
– 1)
2
– 2r
2
 2
The eqn 2 –1 gives,
P
i+1
– P
i
= 2 (x
i
+2)
2
+ y
2
i+1
+ (y
i+1
– 1)
2
– 2r
2
– 2 (x
i
+1)
2
– y
i
2
– (y
i
– 1)
2
+ 2r
2
P
i+1
– P
i
= 2[(x
i
+2)
2
– (x
i
+1)
2
] + y
i+1
2
+ (y
i+1
– 1)
2
– y
i
2
– (y
i
 1)
2
P
i+1
– P
i
= 2[x
i
2
+4x
i
+4x
i
2
2x
i
1] + y
i+1
2
+ (y
i+1
– 1)
2
– y
i
2
– (y
i
– 1)
2
P
i+1
– Pi = 2(2x
i
+3) + y
i+1
2
+ y
i+1
2
– 2y
i+1
+ 1 – y
i
2
– y
i
2
+ 2y
i
– 1
P
i+1
– P
i
= 4x
i
+ 6 + 2y
i+1
2
– 2y
i+1
– 2y
i
2
+ 2y
i
P
i+1
= P
i
+ 4x
i
+ 6 + 2 (y
i+1
2
– y
i
2
) –2 (y
i+1
– y
i
)  3
If Pi is negative, then it means that, d
1
< d
2
and hence yi+1 = yi
P
i+1
= P
i
+ 4x
i
+ 6  4
If Pi is positive or zero, then it means that, d
1
f > d
2
and hence
Y
i+1
= y
i
–1
P
i+1
= P
i
+ 4xi + 6 + 2 [(y
i
– 1)
2
– y
i
2
] – 2[y
i
1 – y
i
]
P
i+1
= P
i
+ 4x
i
+ 6 + 2 [y
i
2
– 2y
i
+ 1 – y
i
2
] + 2
P
i+1
= P
i
+ 4x
i
+ 6 + 2 [2y
i
+ 1] + 2
P
i+1
= P
i
+ 4x
i
+ 6 – 4y
i
+ 2 + 2
P
i+1
= P
i
+ 4(x
i
– y
i
) + 10  5
From equations 4 and 5 we can say that, we are in position calculate P
i+1
if we know P
i
.
However, we must know P
i
. Let substitute I = 1 in equation 1 and hence,
P
1
= 2(x
1
+ 1)
2
+ y
1
2
+ (y
1
– 1)
2
– 2r
2
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
The first point to be drawn is (x
1
, y
1
) = (0, r)
P
1
= 2(0 + 1)
2
+ r
2
+ (r – 1)
2
– 2r
2
P
1
= 2 + r
2
+ r
2
– 2r+1 – 2r
2
P
1
= 2 + 2r
2
– 2r + 1 –2r
2
P
1
= 3 – 2r  6
The above process can be summarized in steps as follows
Algorithm –
1) Read the radius r and center coordinates as (x
c
, y
c
).
2) Select first point for display, (x
1
, y
1
) = (0, r)
3) Calculate the first parameter as,
P ÷ 3 – 2r
4) While (x < = y) do following steps (step 5, 6 & 7)
5) Call display routine
6) If P < 0 Then P ÷ P + 4x + 6
Else
Begin
P ÷ P + 4 (x – y) + 1
y ÷ y – 1
7) Increment x in unit steps as, x ÷ x + 1
Let us assume that (x
i
, y
i
) is drawn. The next point to be drawn is to be determined. It will
be either (x
i
+1, y
i
) or (x
i
+1, y
i
1). If the midpoint is inside the circle, then (x
i
+1, y
i
) is closer
to circle path. If the midpoint is outside the circle, then (x
i
+1, y
i
1) is closer to the circle
path. The decision parameter P
i
is calculated as follows,
P
i
= f
circle
(x
i
+ 1, y
i
– ½)
P
i
= (x
i
+ 1)
2
+ (y
i
– ½)
2
– r
2
 1
The successive decision parameter P
i+1
is obtained as follows,
P
i+1
= f
circle
(x
i+1
+ 1, y
i+1
– ½)
P
i+1
= (x
i+1
+ 1)
2
+ (y
i+1
– ½)
2
– r
2
P
i+1
= (x
i
+ 2)
2
+ (y
i+1
– ½)
2
– r
2
 2
The equation 2 – 1 gives,
P
i+1
– P
i
= (x
i
+2)
2
+ (y
i+1
– ½)
2
– r
2
– (x
i
+1)
2
– (y
i
– ½)
2
+ r
2
P
i+1
– P
i
= (x
i
2
+ 4x
i
+ 4) + (y
i+1
– ½)
2
– (x
i
2
+ 2x
i
+ 1) – (y
i
– ½)
2
P
i+1
– P
i
= 2x
i
+ 3 + (y
i+1
– ½)
2
– (y
i
– ½)
2
P
i+1
= P
i
+ 2x
i
+ 3 + (y
i+1
– ½)
2
– (y
i
– ½)
2
 3
If P
i
is negative, then the midpoint lies inside the circle.
Y
i+1
= y
i
. By substituting this condition in eqn 3, we get
P
i+1
= P
i
+ 2x
i
+ 3  4
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
If Pi is positive or zero, then midpoint lies outside the circle or on the circle. yi+1 = yi –
1. By substituting this condition in equation 3 we get,
P
i+1
= P
i
+ 2x
i
+ 3 + (y
i
– 3/2)
2
– (y
i
– ½)
2
P
i+1
= P
i
+ 2x
i
+ 3 + y
i
2
– 3y
i
+ 9/4 – y
i
2
+ y
i
– ¼
P
i+1
= P
i
+ 2x
i
+ 3 – 2y
i
+ 2
P
i+1
= P
i
+ 2 (x
i
– y
i
) + 5  5
From equations 4 and 5 we can say that, we are in position to calculate P
i+1
, if we know
P
i
. However, we must know P
i
. Let us substitute i = 1 in eqn 1 and hence,
P
1
= (x
1
+ 1)
2
+ (y
1
– ½)
2
– r
2
P
1
= (0 + 1)
2
+ (r – ½)
2
– r
2
(x
1
, y
1
) = (0, r)
P
1
= 1 + r
2
– r + ¼  r
2
P
1
= 5/4 – r  6
The above process can be summarized in steps as,
Algorithm –
1) Read the radius as r and center coordinates as (x
c
, y
c
)
2) Select first point for display as (x
1
, y
1
) = (0, r).
3) Calculate the first parameter as P
P ÷ 5/4 – r 1 – r
4) While (x < = y) do following steps (step 5, 6 & 7)
5) Call display routine
6) If P < 0 Then P ÷ P + 2x + 3
Else
Begin
P ÷ P + 2(x – y) + 2
y ÷ y – 1
end
7) Increment x in unit steps as x ÷ x +1
Display Routine –
i) putpixel (x
c
+x, y
c
+y) ii) putpixel (x
c
+x, y
c
–y)
iii) putpixel (x
c
–x, y
c
+y) iv) putpizel (x
c
–x, y
c
–y)
v) putpixel (x
c
+y, y
c
+x) vi) putpixel (x
c
+y, y
c
x)
vii) putpixel (x
c
y, y
c
x) viii) putpixel (x
c
y, y
c
x)
Display Routine
i) putpixel (x
c
+x, y
c
+y) ii) putpixel (x
c
+x, y
c
–y)
iii) putpixel (x
c
–x, y
c
+y) iv) putpizel (x
c
–x, y
c
–y)
v) putpixel (x
c
+y, y
c
+x) vi) putpixel (x
c
+y, y
c
x)
vii) putpixel (x
c
y, y
c
+x) viii) putpixel (x
c
y, y
c
x)
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Problem – Using Bresenham’s Circle Algorithm, produce the sequence of at least five
points along the circumference of the circle with the radius 20, centered at (50, 50).
Y = 20
x
i
y
i
P
i
P
i+1
x
i+1
y
i+1
Plotted pixel
0 20 50, 70
0 20 37 31 1 20 51, 70
1 20 31 21 2 20 52, 70
2 20 21 7 3 20 53, 70
3 20 7 11 4 20 54, 70
4 20 11 43 5 19 55, 69
5 19 43 17 6 19 56, 69
6 19 17 13 7 19 57, 69
7 19 13 25 8 18 58, 68
Midpoint Circle Algorithm –
In this algorithm also, the x is incremented in unit steps and the corresponding value of y
is calculated. In this algorithm also, the points are calculated only for 1/8
th
of circle. The
remaining 7/8 of the circle is achieved using symmetry. This process is same as that of in
Bresenham’s algorithm. In midpoint circle algorithm, a circle function is calculated as,
F
circle
(x, y) = x
2
+ y
2
– r
2
From the above equation, we can obtain following points,
< 0 if (x, y) lies inside the circle
f
circle
(x, y) = 0 if (x, y) lies on circle boundary
> 0 if (x, y) lies outside the circle
[DIAGRAM]
Ellipse Drawing Algorithm (Midpoint)
The midpoint ellipse drawing algorithm is applied throughout the 1
st
quadrant according to
the slope of the tagent. In region 1, the magnitude of the slope is less than 1 & hence the
x is incremented in unit steps & y is calculated. The process can be started from (0, ry) in
region 1. In region 2, the magnitude of the slope is greater than 1 and hence y is changed
in unit steps and x is calculated accordingly.
The function of the ellipse can be calculated from the equation of the ellipse.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
The function will have following properties,
< 0 if (x, y) is inside the ellipse,
f
ellipse
(x, y) = 0 if (x, y) is on the ellipse,
> 0 if (x, y) is outside the ellipse.
The new point to be drawn is decided on the sign of the above function. The slope of the
ellipse is to be calculated after defining every point. This is done to check whether the
region 1 is finished or not.
The slope of the tangent to the ellipse at (x, y) can be calculated as shown follows,
r
y
2
x
2
+ r
x
2
y
2
–r
x
2
r
y
2
= 0
Differentiating the above equation with respect to x, we get
AT the junction of two regions, the slope becomes –1. In the first region, xi+1 = xi + 1.
The decision parameter is calculated as
P
1i
= f
ellipse
(x
i
+ 1, y
i
– ½)
P
1i
= r
y
2
(x
i
+ 1)
2
+ rx
2
(y
i
– ½)
2
– r
x
2
r
y
2
 1
The successive decision parameter P1i+1 can be calculated as,
2 2
2
2
2
2
2 2 2 2
2
2
2 2
2
2
2
2
2
2
2
2
) , (
0
1
y x x y ellipse
y x
y
x y
y x x y
r r y r x r y x f
r r r x r
r r y r x r
ry
y
rx
x
÷ + =
= ÷ +
= +
= +
2
2
2
2
2 2
2
. 2
/
0 . 2 . 2
x
y
x
y
x
yr
xr
dx
dy
yr
r x
dx dy
dx
dy
r y ry x
÷
=
÷
=
= +
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
P
1i+1
= r
y
2
(x
i+1
+ 1)
2
+ r
x
2
(y
i+1
– ½)
2
– r
x
2
r
y
2
P
1i+1
= r
y
2 (x
i
+2)
2
+ rx2 (y
i+1
– ½)
2
– r
x
2
r
y
2
 2
The equation 2 – 1 can be given as,
P
1i+1
– P
1i
= r
y
2
(x
i
+2)
2
+ r
x
2
(y
i+1
1/2)
2
– rx
2
ry
2
– r
y
2
(x
i
+1)
2
– r
x
2 (y
i
1/2)
2
+ r
x
2
r
y
2
P
1i+1
– P
1i
= ry
2
[ x
i
2
+ 4x
i
+ 4 – x
i
2
– 2x
i
– 1] + r
x
2
[(y
i+1
– ½)
2
– (y
I
 1/2)
2
]
P
1i+1
– P
1i
= r
y
2
(2x
i
+ 3) + r
x
2
[(y
i+1
– ½)
2
– (y
i
– ½)
2
]
P
1i+1
= P
1i
+ r
y
2
(2x
i
+ 3) + r
x
2
[(y
i+1
– ½)
2
– (y
i
– ½)
2
]  3
If P
1i
is negative then y
i+1
= y
i
. By substituting this condition in equation 3, we get,
P
1i+1
= P
1i
+ r
y
2
(2x
i
+ 3)  4
If P
i
is positive or zero, then y
i+1
= y
i
– 1
P
1i+1
= P
1i
+ r
y
2
(2x
i
+3) + r
x
2
[(y
i
– 3/2)
2
– (y
i
– ½)
2
]
P
1i+1
= P
1i
+ r
y
2
(2x
i
+3) + r
x
2
[y
i
2
– 3y
i
+ 9/4 – y
i
2
+ y
i
– ¼]
P
1i+1
= P
1i
+ r
y
2
(2x
i
+3) + r
x
2
(2y
i
+ 2)  5
Let us calculate P
1i
using (x
1
, y
1
) = (0, ry)
P
1i
= r
y
2
(x
i
+1)
2
+ r
x
2
(y
i
– ½)
2
– r
x
2
r
y
2
P
1i
= r
y
2
(0+1)
2
+ r
x
2
(r
y
1/2)
2
– r
x
2
r
y
2
= r
y
2
+ r
x
2
(r
y
2
– r
y
+ ½) – r
x
2
r
y
2
P
1i
= r
y
2
+ r
x
2
r
y
2
– r
x
2
r
y
+ ¼ r
x
2
– r
x
2
r
y
2
P
1i
= r
y
2
– r
x
2
r
y
+ ¼ r
x
2
 6
With the above process, we can complete region1. When absolute of slope becomes 1,
the region 1 is finished and the region 2 gets started. In region 2, the y coordinate is
decremented in unit steps. Let us calculate, parametric equations in region 2. The point
(x
i
, y
i
) is drawn. The next point can be either (x
i
, y
I
 1) or (x
i
+ 1, y
i
– 1). The decision
parameter is calculated as,
P
2i
= f
ellipse
(x
i
+ ½, y
i
– 1)
P
2i
= r
y
2
(x
i
+ ½)
2
+ r
x
2
(y
i
– 1)2 – r
x
r
y
2
 7
P
2i+1
= r
y
2
(x
i+1
+ ½)
2
+ r
x
2
(y
i+1
– 1)
2
– r
x
2
r
y
2
P
2i+1
= r
y
2
(x
i+1
+ ½)
2
+ r
x
2
(y
i
– 2)
2
– r
x
2
r
y
2
 8
The equation 8 – 7 gives,
P
2i+1
– P
2i
= r
y
2
[(x
i+1
+ ½)
2
– (x
i
+ ½)
2
] + r
x
2
[(y
i
– 2)
2
– (y
i
– 1)
2
]
P
2i+1
– P
2i
= r
y
2
[(x
i+1
+ ½)
2
– (x
i
+ ½)
2
] + r
x
2
[y
i
2
– 4y
i
+ 4 – y
i
2
+ 2y
i
P
2i+1
= P
2i
+ r
y
2
[(x
i+1
+ ½)
2
– (x
i
+ ½)
2
] + r
x
2
(2y
i
+ 3)  9
If P
2i
is negative, then midpoint lies inside the circle.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
x
i+1
= x
i
+ 1
P2
i+1
= P
2i
+ r
y
2
[(x
i
+ 3/2)
2
– (x
i
+ ½)
2
] + r
x
2
(2y
i
+ 3)
P
2i+1
= P
2i
+ r
y
2
[x
i
2
+ 3x
i
+ 9/4 – x
i
2
– x
i
– ¼] + r
x
2
(2y
i
+ 3)
P
2i+1
= P
2i
+ r
y
2
(2x
i
+ 2) + r
x
2
(2y
i
+ 3)  10
If P
2i
is positive or zero, then midpoint is outside the ellipse or on the ellipse. x
i+1
= x
i
By putting this condition in eqn 9 we get,
P
2i+1
= P
2i
+ r
x
2
(2y
i
+ 3)  11
The P
2i
will be calculated from the last point of region1.
P
2i
= r
y
2
(x
2
+ ½)
2
+ r
x
2
(y
2
– 1)
2
– r
x
2
r
y
2
 12
Algorithm –
The overall process can be summarized in steps as follows,
1) Read the coordinates (x
c
, y
c
) and also read r
x
and r
y
.
2) Calculate the initial value of parameter in region 1.
P
i
÷ r
y
2
– r
x
2
r
y
+ (1/4) r
x
2
3) Select the first point for display as (0, r
y
) i.e. x = 0, y = r
y
4) Calculate slope as
 (r
y
2
x / r
x
2
y)
5) Repeat steps 6, 7, 8, 9 while (abs (slope) < 1)
6) Call display routine
7) If P1 < 0 Then P1 ÷ P1 + r
y
2
(2x + 3)
Else
Begin
P1 ÷ P1 + r
y
2
(2x + 3) + r
x
2
(2y + 2)
y ÷ y – 1
end
8) Increment x in unit steps as x ÷ x + 1
9) Update the slope as – (r
y
2
x / r
x
2
y)
10) Calculate the decision parameter for region 2
P
2
÷ r
y
2
(x + ½)
2
+ r
x
2
(y – 1)
2
– r
x
2
r
y
2
11) Repeat steps 12, 13, 14 while (y > = 0)
12) Call display routine
13) If P2 < 0 Then
Begin
P
2
÷ P
2
+ r
y
2
(2x+2) + r
x
2
(32y)
x ÷ x+1
end
Else P
2
÷ P
2
+ r
x
2
(32y)
Boundary – Fill Algorithm –
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
An area can be filled, by starting at a point inside the figure and painting the interior in a
specified color or intensity. The painting proceeds until the figure’s boundary is
encountered. This method is called as Boundary – fill algorithm.
A boundaryfill algorithm accepts the interior coordinate point (x, y) accepts the fill color
and boundary color, as input parameters. Starting from the given interior point, four
neighbouring points are tested. These points are above, below, right and left to the
starting point. Areas filled by this method are called as 4connected areas.
The boundaryfill algorithm can also be implemented using 8connected areas. In this
case, alongwith four neighbouring pixels, four diagonal pixels are also tested.
[DIAGRAM]
4connected areas 8connected areas
The algorithm can be written in recursive manner. If the neighbouring point is not having
boundary color as well as not having the fill color, then that point is painted with a fill
color. The recursive procedure is written as shown below.
void boundaryfill (int x, int y, int f
c
, int b
c
)
{ int p
c
;
p
c
= getcolor (x, y);
if ( (p
c
! = b
c
)& & (p
c
! = f
c
) )
{ putpixel (x, y, f
c
);
boundaryfill (x+1, y, f
c
, b
c
);
boundaryfill (x1, y, f
c
, b
c
);
boundaryfill (x, y+1, f
c
, b
c
);
boundaryfill (x, y1, f
c
, b
c
);
Floodfill algorithm
Sometimes, an area is not defined with a single color boundary. In the
given diagram, the area is surrounded by areas of different colors. Thus,
the boundary color is not unique. Such areas are filled by replacing the old
color by new color instead of checking boundary colors. This approach is
called as floodfill algorithm. The algorithm starts from a given interior
point 9x, y) and uses either 4connected or 8connected areas method. If
the neighbouring points are of old color, then these points are recolored
with flood color. The floodfill algorithm when reaches towards any
boundary of any other color, then algorithm finds, that the point is of some
different color and hence it is not required to be recolored. The algorithm
can be written recursively as follows,
void floodfill (int x, int y, int f
c
, int o
c
)
{
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
if (o
c
= = getcolor (x, y) )
{ putpixel (x, y, f
c
);
floodfill (x+1, y, f
c
, o
c
);
floodfill (x1, y, f
c
, o
c
);
floodfill (x, y+1, f
c
, o
c
);
floodfill (x, y1, f
c
, o
c
);
}
}
 Both the algorithms are recursive and these algorithms works only for small areas.
 These algorithms can also be made nonrecursive, but then the logic is slightly
complicated than recursive algorithms.
Text Generation –
Letters, numbers, digits and other special symbols can be displayed in variety of sizes
and styles. The overall design style for a set of characters is called as typeface. The
typeface and font are used interchangeably. The typefaces can be divided into two broad
groups as serif and sansserif. The serif type has small lines called as accents at the
ends of main character strokes. The sansserif font does not have accents.
 The text in serif font can be like ABCDEF.
 The text in sansserif font can be like ABCDEF.
Two different representations are used for storing fonts. A simple method to represent
character fonts is to use rectangular grid patterns. The sets of character shapes are
referred as bitmap fonts.
Another method to describe the character shapes in particular font, is using straight lines
or curve sections. In this case, set of characters is called as outline font. To display
characters in outline form, the interior of the character outline is to be filled using some
algorithm.
Bit map fonts are simplest to define and display. The character grid is to be mapped to a
frame buffer position. the bit map fonts can be used to display the characters in different
styles and sizes.
Text Attributes –
The appearance of the characters can be changed by changing the attributes of the
characters. The attributes can be defined as font, size, color and orientation. Attributes
can be set for a single character or group of characters.
There are no. of fonts which are developed for displaying characters, such as Times New
Roman, New York, Courier, Wild Latin, Algerian, Arial etc. These characters can be
displayed with different styles as, italics, boldface, underline. Every graphics package
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
provides these types of facilities. The characters can also be displayed in different sizes
as,
CG, CG, CG,CG,CG,CG
2.7 Bezier Curves 
This method of constructing curves was developed by the French
Engineer Bezier. For any given set of control points, an approximate curve
is formed by adding sequence of polynomial functions, which are formed
from the coordinates of the control points.
The curve is formed by accepting n+1 control points. These points are represented as P
k
(x
k
, y
k
, z
k
) for k varying from a to n. Using these points, the Bezier function p(u) is
calculated as,
where,
The equation 1 can be written as,
¯
=
=
n
k
u n Bk Pk u p
0
) ( , . ) (
)! ( !
!
) 1 ( ). , ( ) ( ,
,
k n k
n
andc u u k n c u n Bk
k n
k n k
÷
= ÷ =
÷
¯
¯
¯
=
=
=
=
=
=
n
k
n k k
n
k
n k k
n
k
n k k
u B z u z
u B y u y
u B x u x
0
,
0
,
0
,
) ( . ) (
) ( . ) (
) ( . ) (
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
The polynomials B
k,n
(u) are called as Blending functions. This is because, these
functions blend (mix) the control points to form composite function. The blending
functions will be polynomials of degree n, if n+1 control points are given.
If the curves are restricted on xy plane for z = 0 then z(u) = 0. The Bezier curve always
lies inside the CONVEX HULL represented by central points. The following diagrams
represents different curves alongwith convex hull represented with dotted lines.
If the curve is defined by 4 points, it means that n+1 = 4. Hence n = 3. In this case, k will
be varying from 0 to 3. Thus, there will be 4 Blending functions as, B
0,3
(u), B
1,3
(u), B
2,3
(u)
and B
3,3
(u). All these functions can be calculated using B
k,n
(u).
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
it means that, while defining the curve, all the blending functions are used and hence all
of them have some effect to determine each point on the curve. For different ranges of u,
different blending functions are dominent than other blending functions. This feature
provides facility of localized control over the curve.
2.8 BSpline Curves –
The spline is a flexible strip, used to produce the smooth curve, through set of given
points. In Bspline curve, n+1 control points are given. These points are denoted as P
k
(x
k
, y
k
, z
k
), where k varies from 0 to n. the Bspline curve can then be defined as,
Where, N
k,t
(u) can be defined as polynomials of degree t1. A polynomial form of the
blending function can be defined recursively, over various subintervals of range of u.
This range depends on n and t. The u varies from 0 to n – t + 2.
 The blending functions are recursively defined as,
N
k,t
= 1 if u
k
s u < u
k+1
= 0 otherwise
 Any term divided by 0 in above calculation is assumed as zero.
 The positions u
j
are defined as breakpoints. The breakpoints are defined as follows,
 The j varies from 0 to n + t.
 Using the recursive blending functions and by putting proper values of u
j
, the
Blending functions N
k,t
(u) are evaluated with respect to u.
 Let us take 5 control points. n + 1 = 5 n = 4
¯
=
=
n
k
n k k
u B P u P Since
0
,
) ( . ) ( ,
¯
=
=
n
k
t k k
u N P u P
0
,
) ( . ) (
) ( ) ( ) (
1 , 1
1
1 ,
1
,
u N
u u
u u
u N
u u
u u
u N
t k
k t k
t k
t k
k t k
k
t k ÷ +
+ +
+
÷
÷ +
÷
÷
+
÷
÷
=
¦
¹
¦
´
¦
> + ÷
s s + ÷
<
=
n ifj t n
n j ift t j
t ifj
u
j
2
1
0
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Let us take t = 3. The typical blending functions are defined as follows,
u varies from 0 to n – t + 2 i.e. 0 to 4 – 3 + 2 i.e. 0 to 3.
j varies from 0 to 4 + 3 i.e. 0 to 7.
u
0
= 0, u
1
= 0, u
2
= 0
u
3
= 1, u
4
= 2
u
5
= 3, u
6
= 3, u
7
= 3
Using these breakpoints, the blending functions are plotted with respect to u.
2.9 Properties of Curves (Bezier as well as Bspline)
Following are the general properties of the curves.
1) Control Points – The shape of the curve is controlled by the location of control points.
If the curve passes through the control points, then they are called as knots. A curve
is said to interpolate, the control points if it passes through them. The curve often
remains within the CONVEX HULL, which is formed by joining control points.
2) Multiple Values – In general, a curve is not a graph of a single valued function of a
coordinate.
It means that f(x) can have two or more values for the same value of x. Similarly, f(y) can
have two or more values for the same value of y.
From the diagram, we can see that, at value y, there
are three different values of x on the curve as x
1
, x
11
& x
111
.
Similarly, at value x, there are two different values of
y on the curve as y
1
and y
11
.
3) Axis Independence – The shape of an object
must not change when control points are
measured in a different coordinate system. For
e.g. if the control points are rotated (means
coordinate axis is) by 90°, the curve should
rotate by 90°, but the shape will not change.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
4) Global or Local Control – When the designer manipulates (modifies) a particular
control point, then it may change the shape throughout, or a curve may change
shape only in the region near the control point. The first behaviour is called as global
control and the second behaviour is called as local control. The global control may be
annoying for designer if he is trying for fine adjustment.
5) Variationdiminishing property – Some mathematical functions used to determine the
curve are such, that curve oscillates heavily, whereas some mathematical functions
are such that curve goes smoothly. This is because, these functions have variation
diminishing property. It means that, f (u
k+1
) – f(u
k
) decreases as k increases.
heavyascillations variasiondiminishing curve.
6) Versatility – A curve representation that allows limited variety of shapes can frustrate
designer. More flexible techniques allow the designer to control the versatility of a
curve, by adding or removing control points. For e.g. if two points are given and if we
get a line, then just by placing the third control point, number of additional shapes
can be achieved. Ore to control points more the accuracy.
Order of continuity – Usually, a complex shape is not modelled by a single curve, but by
several curves pieced together. Such joints are to achieve sharp corners. While creating
joints, designer will have options to control the order of continuity.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
5
* 20 GEOMETRIC TRANSFORMATION *
GEOMETRIC TRANSFORMATION ÷ Matrices, scaling transformations, (sine & cos
rotation), homogeneous rotation & translation, Rotation about on arbitrary point, inverse
transformation.
1. Two Dimensional Transformation
1.1 Translation
1.2 Rotation
1.3 Scaling
2. Homogeneous Coordinates For
2.1 Translation
2.2 Rotation
2.3 Scaling
3. Rotation about an arbitrary point.
4. Reflection & shear.
5. Inverse Transformations.
1.1 TRANSLATION
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 Translation is a process of changing the position of an object in a straight line path
from one coordinate location to another.
 We can translate a two dimensional point by adding translation distances t
x
and t
y
to
the original coordinate position (x, y) to move the point to a new position (x
1
, y
1
) as
shown in the figure above.
x
1
= x + t
x
÷ 1
y
1
= y + t
y
÷ 2
 The translation distance pair (t
x
, t
y
) is called a translation vector or shift vector.
 Equations 1 & 2 can be expressed in the form of following translation vector.
The 2 dimensional translation equations is the matrix form:
P
1
+ P + T
+
=
y
x
t
t
y
x
y
x
e i
1
1
. .
Ex. Translate a polygon with coordinates A (2, 5), B (7, 10) and C (10, 2) by 3 units in x
direction and 4 units is y direction.
=
=
=
y
x
t
t
T
y
x
P
y
x
P
1
1
1
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
=
+
= + =
=
+
= + =
=
+
= + =
6
13
4
3
2
10
14
10
4
3
10
7
9
5
4
3
5
2
1
1
1
T C C
T B B
T A A
1.2 ROTATION
A two dimensional rotation is applied to an object by repositioning it along a circular path
in the xy plane. To generate a rotation, we specify rotation angle 0 and the position of the
rotation about which the object is to be rotated.
 Let us consider the rotation of an object about the origin as shown in the fig. below.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 Here, r ÷ constant distance of point from the origin,
o ÷ original angular position of point from horizontal.
u ÷ Rotation Angle.
 Using trignometary,
x
1
= r cos(o + u) = r cos o cos u  r sin o sin u
y
1
= r sin (o + u) = r cos o sin u + r sin o cos u ÷ 1
 The original coordinates are
x = r cos o
y = r sin o ÷ 2
 Substituting 2 in 1, we get,
x
1
= x cos u  y sin u
y
1
= y sin u + y cos u ÷ 3
 The above equations can be represented in the matrix form
R P P
xy y x
.
cos sin
sin cos
] [ ] [
1
1 1
=
÷
=
Where R ÷ Rotation Matrix and it is given as
÷
=
cos sin
sin cos
R
Note, For negative values of 0,
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
÷
=
÷ ÷ ÷
÷ ÷
=
cos sin
sin cos
) cos( ) sin(
) sin( ) cos(
R
R
Ex. A point (4, 3) is rotated conter clockwise by an angle of 45°. Find the rotation matrix
and the resultant point.
Sol.
2 / 7 2 / 1 [
] 2 3 2 / 4 2 / 3 2 / 4 [
2 1 2 / 1
2 1 2 / 1
] 43 [
2 / 1 2 / 1
2 / 1 2 / 1
45 cos 45 sin
45 sin 45 cos
cos sin
sin cos
1
=
+ ÷ =
÷
=
÷
=
° ° ÷
° °
=
÷
=
P
R
1.3 SCALING
A scaling transformation changes the size of an object. This operation can be carried out
for polygons by multiplying the coordinate values (x, y) of each vertex by scaling factors
Sx and Sy to produce the transformed coordinates (x1, y1)
x
1
= x.S
x
& y
1
= y. S
y
÷ 1
Scaling factor S
x
scales object in x direction and scaling factor S
y
scales object in y
direction.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 The equation 1 can be written in matrix form as
S P
S y S x
S
S
xy y x
y x
y
x
.
] . . [
0
0
] [ ] [
1 1
=
=
=
Values assigned to S
x
& S
y
that are less than 1, reduce the size of the object and values
greater than 1 enlarge the size of the object.
Ex. Scale a polygon with coordinates A (2, 5), B (7, 10), C (10, 2) by 2 units in x direction
& 2 units in y direction.
Soln. Here S
x
= 2 & S
y
= 2
Transformation matrix is given as
] 204 [
02
20
] 102 [ ] [
] 1420 [
02
20
] 710 [ ] [
] 410 [
02
20
] 25 [ ] [
] 102 [
] 710 [
] 25 [
02
20
3
1
3
1 1
2
1
2
1 1
1
1
1
1 1
=
= =
=
= =
=
= =
=
y x C
y x B
y x A
C
B
atrixisA Theobjectm
S
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
2. HOOGENEOUS COORDINATES
 In design and picture formation process, many times we may require to perform
translation, rotations and scaling to fit the picture components into their proper
positions.
 Each of the basic transformation can be expressed in the general matrix form as
P
1
= P . M
1
+ M
2
÷ 1
nMatrix Translatio M
trix IdentityMa M e i
ty
tx
P tionP ForTransla
=
=
+
=
2
1
1
. .
01
10
0
. .
0
0
0
0
0
0
0
cos sin
sin cos
2
1
1
2
1
1
=
=
+
=
=
=
+
÷
=
M
rix ScalingMat M e i
S
S
P P ForScaling
M
Matrix Rotational M
P nP ForRotatio
y
x
 To produce a sequence of transformations with the above equations, we must
calculate the transformed coordinates are translated, then they are scaled and finally
rotated. But this sequential approach is not efficient.
 A more efficient approach is to combine sequence of transformations into one
transformation so that the final coordinate positions are obtained directly from the
initial coordinates. This eliminates the calculation of intermediate values.
 To achieve this we have to eliminate the matrix addition associated with the
translation terms in M
2
of eqn 1.
 We have to represent matrix M
1
as 3 x 3 matrix instead of 2 x 2 introducing an
additional demmy coordinate w. Here, points are specified by 3 numbers instead of
2.
 This coordinate system is called Homogeneous coordinate system and it allows us
to express all transformation equations as matrix multiplication.
 The homogeneous coordinate is represented as a triplet.
(Xw, Yw, W) where
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
W
Yw
y
W
Xw
x = = &
Each 2 dimensional position can be represented with homogeneous coordinate as (x,
y, 1)
Summary ÷
Homogeneous coordinates allow combined transformation, eliminating the calculation of
intermediate coordinate values and thus save required time for transformation and
memory required to store the intermediate coordinate values.
2.1 HOMOGENEOUS COORDINATES FOR TRANSLATION
The homogeneous coordinates for translation are
] 1 [
1
010
100
] 1 [ ] 1 [
1
010
100
1 1
ty txy x
t t
xy y x wehave
t t
T
y x
y x
+ + =
=
=
2.2 HOMOGENEOUS COORDINATES FOR ROTATION
Homogeneous Coordinates for
] 1 cos sin sin cos ] 1 [
001
0 cos sin
0 sin cos
] 1 [ ] 1 [
001
0 cos sin
0 sin cos
1 1
1 1
y x y x y x
xy y x
RotationR
+ ÷ =
÷ =
÷ =
2.3 HOMOGENEOUS COORDINATES FOR SCALING
Homogeneous Coordinates for scaling are
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
] 1 . . [
001
0 0
00
] 1 [ ] 1 [
001
0 0
00
1 1
y x
y
x
y
x
S y S x
S
S
xy y x
S
S
S
=
=
=
Note ÷ In the above texts 2.1 to 2.3 the object matrix is written first and is then multiplied
by required transformation matrix. If we wish to write the transformation matrix first and
then the of object matrix we have to take the transpose of both the matrices and post
multiply the object matrix.
=
1
001
01
10
1
. .
1
1
y
x
t
t
y
x
e i
y
x
Ex 1. Consider a square ABCD with coordinate position A (1, 1), B (3, 1), C (3, 3), & D(1,
3). Consider the centre position (2, 2). Perform the following transformations.
Reduce it to ½ its size with centre still at (2, 2)
The transformation is carried out in the following sequence.
1. Translate the square such that its centre coincides with origin.
2. Scale the square with respect to the origin.
3. Translate the square back to the original position.
Thus overall transformation matrices is formed by multiplication of 3 matrices.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
) 5 . 2 , 5 . 1 ( ) 5 . 2 , 5 . 2 (
) 5 . 2 , 5 . 2 ( ) 5 . 1 , 5 . 1 (
] 51 . 52 . 1 [
111
50 . 00
500 . 0
] 131 [ ] . . .[
] 51 . 52 . 2 [
111
50 . 00
500 . 0
] 331 [ ] . . .[
] 51 . 51 . 2 [
111
50 . 00
500 . 0
] 311 [ ] . . .[
] 51 . 51 . 1 [
111
50 . 00
500 . 0
] 111 [ ] . .[
111
50 . 00
500 . 0
221
010
100
11 1
50 . 00
500 . 0
221
010
100
.
001
50 . 00
500 . 0
.
21 2
010
100
. .
221
010
100
001
50 . 00
500 . 0
21 2
010
100
1
1
1 1
2 1
1
1
2 1
1
1
2 1
1
1
2 1
1
2 1
2
= =
= =
=
= =
=
= =
=
= =
=
= =
=
÷ ÷
=
÷ ÷
=
=
=
÷ ÷
=
D B
C A
T S T D D
C
T S T C C
B
T S T B B
A
T S T A A
T S T
T S T
D
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
2. Give a 3 x 3 homogeneous coordinate transformation matrix for each of the following
translations.
a) Shift the image to the right 3 unit
b) Shift the image up 2 unit
c) Move the image down ½ unit and right 1 unit.
d) Move the image down 2/3 unit and left 4 units.
Soln. Homogeneous Coordinates for translation are
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
÷
=
= ÷ =
=
= ÷ =
=
= =
=
= =
=
661 . 40
010
100
66 . 0 , 4 )
51 . 10
010
100
1 , 5 . 0 )
021
010
100
2 , 0 )
301
010
100
0 , 3 )
1
010
100
T
ty Heretx d
T
tx Herety c
T
ty Heretx b
T
ty Heretx a
txty
T
3. Find the transformation of a triangle A(1,0), B(0,1), C(1,1) by
a) Rotating 45° about the origin and translating one unit in x & y direction.
b) Translating one unit in x and y direction and then rotating 45° about the origin.
Soln.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
The Rotation matrix is
) 2 / 3 , 2 / 1 (
] 1 2 / 3 2 / 1 [
1 2 0
0 2 / 1 2 / 1
0 2 / 1 2 / 1
] 101 [
] . .[
1 2 0
0 2 / 1 2 / 1
0 2 / 1 2 / 1
001
0 2 / 1 2 / 1
0 2 / 1 2 / 1
.
111
010
100
. )
) 1 2 , 1 (
1
2
1
, 1
2
1
, 1
2
1
, 1
2
1
11
2
1
1
2
1
111
0 2 / 1 2 / 1
0 2 / 1 2 / 1
] 101 [
] . .[
111
0 2 / 1 2 / 1
0 2 / 1 2 / 1
111
010
100
001
0 2 / 1 2 / 1
0 2 / 1 2 / 1
. )
111
010
100
&
001
0 2 / 1 2 / 1
0 2 / 1 2 / 1
001
450 cos 45 sin
450 sin 45 cos
1
1
1
1 1
1
=
=
÷ =
=
÷ =
÷
=
+ =

.

\

+ + ÷ = 
.

\

+ + =
+ + =
÷ =
=
÷ =
÷ =
=
÷ =
÷ =
A
R T A A
R T b
C
B A
T R A A
T R a
T
nmatrixis Translatio
R
R
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
) 2 / 3 , 2 / 1 (
] 1 2 / 3 2 / 1 [
1 2 0
0 2 / 1 2 / 1
0 2 / 1 2 / 1
] 011 [
] . .[
1
1
÷ =
÷ =
÷ =
=
B
R T B B
) 2 2 , 0 (
] 1 2 / 02 [
1 2 0
0 2 / 1 2 / 1
0 2 / 1 2 / 1
] 111 [
.] . .[
1
1
=
=
÷ =
=
C
R T C C
3. Rotation about an arbitrary point
To rotate an object about an arbitrary point we have to carry out 3 steps.
1. Translate point (xp, yp) to origin
2. Rotate it about the origin.
3. Finally, translate the centre of rotation back where it belongs.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
1. The translation matrix to move point (xp, yp) to the origin is
2. The rotation matrix for counter clockwise rotation of point below the origin is
3. The translation matrix to move the centre point back to its original position is given as
÷ ÷
=
1
010
100
1
yp xp
T
÷ =
001
0 cos sin
0 sin cos
R
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
=
1
010
100
2
xpyp
T
Therefore, the overall transformation matrix for a counter clockwise rotation by an angle
& about the point (xp, yp) is given as
+ ÷ ÷ + + ÷
÷ =
÷
÷ ÷
=
1 cos sin sin cos
0 cos sin
0 sin cos
1
010
100
001
0 cos sin
0 sin cos
1
010
100
. .
2 1
yp yp xp xp yp xp
xpyp yp xp
T R T
Ex. 1. Perform a counterclockwise 45° rotation of triangle A(2,3), B(5,5), C(4,3) about
point (1,1)
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Soln. Here xp = 1, yp = 1 u = 45°
÷ =
÷ =
=
÷ ÷
=
001
0 2 / 1 2 / 1
0 2 / 1 2 / 1
001
450 cos 45 sin
450 sin 45 cos
111
010
100
,
11 1
010
100
2 1
R
T T
We have
the standard formula.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!

.

\

+ + =
+ + =
+ ÷ + + ÷ =
+ ÷
÷
÷
=
=

.

\

+ =
+ ÷ + + ÷ =
+ ÷
÷ =
=

.

\

+ + ÷ =
+ ÷ + + ÷ =
+ ÷
÷ =
=
+ ÷
÷ =
+ ÷ ÷ + ÷
÷ =
+ ÷ ÷ + + ÷
÷ =
1
2
5
, 1
2
1
1
2
5
11
2
1
11 2
2
3
2
4
1
2
3
2
4
11 2 1
0 2 / 1 2 / 1
0 2 / 1 2 / 1
0 2 / 1 2 / 1
] 431 [
] . . [
1
2
8
, 1
11 2
2
5
2
5
1
2
5
2
5
11 2 1
0 2 / 1 2 / 1
0 2 / 1 2 / 1
] 551 [
] . . [
2
3
1 , 1
2
1
11 2
2
3
2 1
2
3
2
11 2 1
0 2 / 1 2 / 1
0 2 / 1 2 / 1
] 231 [
] . . .[
11 2 1
0 2 / 1 2 / 1
0 2 / 1 2 / 1
11 2 / 1 2 / 1 2 / 1 2 1
0 2 / 1 2 / 1
0 2 / 1 2 / 1
. .
,
1 cos sin sin cos
0 cos sin
0 sin cos
. .
1
2 1
1
1
2 1
1
1
2 1
1
2 1
2 1
C
T R T C C
B
T R T B B
A
T R T A A
T R T
get ngvalueswe Substituti
yp yp xp xp yp xp
T R T
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
4. REFLECTION & SHEAR
Besides the 3 basic transformations, there are some other transformations which are
useful in certain applications. Two such transformations are Reflection & Shear.
4.1 REFLECTION
 A reflection is a transformation that produces a mirror image of an object relative to
an axis of reflection.
 We can choose an axis of reflection in the xy plane or perpendicular to the xy plane.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
COMMON REFLECTIONS
4.2 SHEAR
 A transformation that slants the shape of an object is called the shear transformation.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 Two common sharing transformations are used.
One shift x coordinate values and other shifts y coordinate values. In both cases
only one coordinate (x or y) changes its coordinate while the other preserves it.
4.2.1 X SHEAR
The x shear preserves the y coordinate but changes the x values which causes vertical
lines to the left or right as shown below. The transformation matrix for x shear is given as
4.2.2 Y SHEAR
The Y shear preserves the x coordinate, but changes the y values which causes
horizontal lines to transform into lines which slope up as down as shown in figure. The
transformation matrix for y shear is given as
X Ysh y y
X X
Sh
sh Y
y
.
&
001
010
0 1
_
1
1
+ =
=
=
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
4.2.3 Shearing Relative to other Reference Line
We can apply x shear & y shear transformations relative to other reference lines. In x
shear transformation we can use y reference line & in y shear transformation we can use
x reference line.
Transformation matrices are
Ex. 1. Apply the shearing transformation to square with A(0,0), B(1,0), C(1,1), D(0,1) as
below.
a) Shear parameter value of 0.5 relative to line y
ref
= 1
b) Shear parameter of 0.5 relative to line x
ref
= 1.
a) Soln. Here Sh
x
= 0.5 and y
ref
= 1
÷
=
÷
=
1 0
010
0 1
01 .
10
100
ref y
y
ref x
x
x Sh
Sh
line xreference yshearwith
y sh
Sh line yreference Xshearwith
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
) 1 , 1 ( ) 0 , 5 . 1 (
) 1 , 2 ( ) 0 , 5 . 0 (
] 111
] 211 [
] 500 . 1 [
] 501 . 0 [
501 . 0
510 . 0
100
011
111
101
001
01 .
10
100
1 1
1 1
1
1
1
1
1
1
1
1
= =
= =
=
=
=
=
=
÷
=
=
=
=
D B
C A
D
C
B
A
Y Sh
Sh D D
C C
B B
A A
ref x
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
b) Here Sh
y
= 0.5 and X
ref
= 1
) 5 . 1 , 0 (
) 2 , 1 (
) 1 , 1 (
) 5 . 0 , 0 (
51 . 01
121
111
51 . 00
51 . 50 . 0
510 . 0
50 . 10
011
111
101
001
1 0
010
0 1
1
1
1
1
1
1
1
1
=
=
=
=
=
=
÷
=
D
C
B
A
X Sh
Shy
D
C
B
A
D
C
B
A
ref y
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
NOTE: It is important to note that shearing operations can be expressed as sequence of
basic transformations. The sequence of basic transformation involves series of rotation
and scaling transformation.
Ex. Show how shear transformation may be expressed in terms of rotation & scaling.
Soln.
 The shear transformation matrix for x and y can be combinely given as

001
10
0 1
Shx
Shy
 We have the scaling and rotation matrix as

÷ =
=
001
0 cos sin
0 sin cos
001
0 0
00
R S
S
S
y
x
 If we combine scale matrix & rotation matrix we have
÷ =
001
0
0
.
Cos S Sin S
Sin S Cos S
R S
y y
x x
Comparing shear matrix & S. R. matrix we have
Sh
x
=  S
y
Sin u
Sh
y
= S
x
Sin u
S
x
Cosu = 1
S
y
Cosu = 1
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
cos
1
cos
1
=
=
y
x
S
and S
Substituting values for S
x
& S
y
we get,
tan
cos
1
tan
cos
1
= =
÷ =
÷
=
Sin Sh
Sin Sh
y
x
The shear transformation matrix expressed in terms of rotation & scales is
yscale S
xscale S
ation AngleofRot
Cos S Cos S
y
x
y x
÷
÷
÷
= =
÷
1
001
10 tan
0 tan 1
O
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
6
2D VIEWING
Viewing pipeline, viewing coordinates reference frame, window to view part coordinate
transformation, 2D viewing function, clipping operations, port clipping, line dipping,
Sutherland / Cohens line clipping algo, polygon clipping algo, Sutherland/Hodgeman
polygon clipping algorithm.
 We can use variety of transformations like scaling, rotation, reflection etc to generate
a variety of different views of a single picture e.g. a map, or any other picture.
1. In a map, we might be interested in the northern region only, in such a case we need
some method do display only those portions of the drawing that are of immediate
interest. This gives the effect of looking at the image through a window.
The process of selecting and viewing the picture is called windowing.
2. CLIPPING
The remaining portion which are not of immediate interest must not be visible. The
technique to do so is called ‘CLIPPING’
The process of discarding the portion of a picture which is outside the window (in
which we are not interested) is called CLIPPING.
3. VIEWING TRANSFORMATION
 A picture is stored in the computer memory in WCS WORLD COORDINATE
SYSTEM.
 However when the picture is displayed on the display device it is measured in
physical device coordinate system (PDCS) corresponding to the display device.
 Therefore displaying an image of a picture involves mapping the coordinates of the
points and lines that form the picture into the appropriate physical device coordinate
where the image is to be displayed. This mapping of coordinates is achieved with
the use of coordinate transformation known as viewing transformation i.e. the
viewing transformation maps picture coordinate in the WCS to display coordinates in
PDCS.
4. The Viewing Pipeline
 If an object is too complex to be shown entirely or we are particularly interested in
just a portion of it, we would like to imagine a box about a portion of the object and
display what is enclosed in the box. Such a box is called Window.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 In terms of coordinates it refers to the World Coordinate area for display.
 When we change the window parts of the object at the same position on display.
 It might happen that we don’t wish to use the entire screen for display, we would like
to image a box on the screen and have the image confined to that screen. Such a
box on the screen is called Viewport.
 An area on the display device / screen to which a window is mapped is called
Viewport.
 A window defines what is to be viewed and the viewport defines where it is to be
displayed.
5. Relation between the window coordinate and viewport coordinate
 Once we know the extend of the image in the window, we need to defiune or select
the extend of the viewport.
 While transforming the description from the window to the viewport we have to
maintain a relative placement of the object i.e. if a coordinate position is at the centre
of a window, it should be displayed at the centre of the viewport.
min max
min
min max
min
Wx Xw
Xw Xw
Xv Xv
Xv Xv
÷
÷
=
÷
÷
 The window defined is the world coordinate is transformed to viewport coordinates
by performing the following steps.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
1) The part of the object to be displayed is selected in the window.
2) The object together with its window is translated until the lower left corner of the
window is at the origin.
3) The object and the window are scaled until the window has the dimensions of the
viewport.
4) Translate the viewport to its correct position in the screen
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
The transformation is given as
W = T.S.T
1
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
÷ ÷
=
÷ ÷
= =
=
÷
÷
=
÷
÷
=
=
÷ ÷
=
1
0 0
00
1
010
100
001
0 0
00
1
010
100
. .
1
010
100
001
0 0
00
1
010
100
min min min min
min min min min
1
min min
1
min max
min max
min max
min max
min min
y w v x w v
y
x
v v
y
x
w w
v v
w w
v v
y
w w
v v
x
y
x
w w
S Y Y S X X
S
S
Y X
S
S
Y X
T S T W
Y X
T
Y Y
Y Y
S
X X
X X
S
S
S
S
Y X
T
6. 2D CLIPPING
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 The portion of the picture inside the window should be displayed and the other areas
should not be displayed. The technique used to do so is called CLIPPING.
 The process allowing the unwanted / invisible portion of the picture to be discarded is
called CLIPPING.
 The clipping algorithm determines which points, lines or portions of the lines be within
the window. These lines are retained for display. All others are discarded.
7. POINT CLIPPING
 The points are said to be interior to the clipping window if
X
wmin
s X s X
wmax
and
Y
wmin
s Y s Y
wmax
The equal sign indicates that points on the window boundary are induced within the
window.
6. LINE CLIPPING
 The lines are said to be interior to the clipping window & hence visible if both end
points are interior to the window.
 If both the endpoints are completely to the right, left, above or below the window,
then the line is completely exterior to the window & hence invisible.
 If both endpoints of line are outside the window the line is not necessarily completely
outside.
 It requires the calculation of intersection points to decide the visible portion of them.
All this is done by following certain algorithms.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
SUTHERLAND & COHEN SUBDIVISION LINE CLIPPING ALGORITHM
 It is one of the oldest and most popular line clipping algorithm developed by Dan
Cohen and Ivan Sutherland.
 This algorithm uses a four digit (but) code to indicate which of the nine regions
contain the end points of line. The four bit codes are called region codes or outcodes.

 Once we have established the region codes for all the line endpoints we can
determine which lines are completely inside the clipping window & which are clearly
outside.
 This is done through logical AND operations. If the result of AND operation is not
0000, the line is completely outside the clipping region and if both points are inside
the window the line is completely outside & is visible.
 The lines which cannot be identified as completely inside or outside the window by
these tests are checked for intersection with window boundaries.
e.g. Consider the clipping window & the lines shown in fig below. Find the region codes
for each point & identify whether the line is completely visible, partially visible or
completely invisible.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Line Line Point Codes Logical AND Result
P
1
P
2
0000 0000 0000 Comp. Visible
P
3
P
4
0001 0001 0001 Comp. Invisible
P
5
P
6
0001 0000 0000 Partially Visible
P
7
P
8
0100 0010 0000 Partially Visible
P
9
P
10
1000 0010 0000 Partially Visible
The Sutherland Cohen algorithm begins the clipping process for partially visible line by
comparing an outside endpoint to a clipping boundary to determine how much of the line
can be discarded. Then the remaining part of the line is checked against the other
boundaries & the process is continued until either the line is totally discarded as a section
is found inside the window.
a) The line P
1
P
2
is partially visible.
b) Starting with P
1
, the intersection point P1 is found and we get
the 2 line segments P
1
P
1
1
& P
1
1
P
2
.
c) We know that for P
1
P
1
1
one endpoint P
1
is outside the window &
thus the line segment P
1
P
1
1
is discarded. The line is now
reduced to the section from P
1
1
to P
2
.
d) Since P
2
is outside the window, it is checked again for
boundaries and intersection pt P
2
1
is found. Again the line
segment is divided into 2 segments giving P
1
1
P
2
1
&P21P
2
.
e) For P
2
1
P
2
one endpoint P
2
is outside the window & thus the
line segment P
2
1
P
2
is discarded. The remaining part of the
line segment P
1
1
P
2
1
is completely inside the clipping window
& hence made visible.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
The intersection points with a clipping boundary can be calculated using the slope
intercept form of the line equation. The equation for line passing through points
P
1
(x1, y
1
) & P
2
(x
2
, y
2
) is
Y = m(x – x
1
) + y
1
or y = m(x – x
2
) + y
2
e slopeoflin
x x
y y
wherem
1 2
1 2
÷
÷
=
SUTHERLAND & COHEN SUBDIVISION LINE CLIPPING ALGORITHM
1. Read the 2 line endpoints P
1
(x
1
, y
1
) P
2
(x
2
, y
2
)
2. Read the coordinates of window.
3. Assign region codes for nine region to find out which region has the end pts.
4. Check for visibility of line P
1
P
2
a) If region codes for both endpoints are zero, then line is completely visible. Hence,
draw the line & go to step 9.
b) If the region codes for endpoints are not zero and logical ENDing of them is also
nonzero then the line is completely invisible so reject the line and go to step 9.
c) If the region codes for the 2 end points do not satisfy the above conditions a) & b)
then line is partially visible.
5. Determine the intersecting edge of the clipping window by inspecting the region
codes of 2 end points.
a) If the region codes for both the end points are non zero, find intersection points
P
1
1
& P
1
with boundary edges of clipping window with respect to point P
1
& point
P
2
respectively.
b) If region code for anyone end point is non zero then find intersection point P
1
1
as
P
2
2
with the boundary edge of the clipping window with respect to it.
6. Divide the line segments considering intersection points.
7. Reject the line segment if any one endpoint appears outside the clipping window.
8. Draw the remaining line segments.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
9. Stop.
9. POLYGON CLIPPING
 Polygon is a collection of lines. Therefore we might think that the line clipping can be
used directly for polygon clipping.
 However, when a closed polygon is clipped as a collection of lines with the line
clipping algorithm, the original closed polygon becomes one or more open polygon or
discrete lines. Thus we need to modify the line clipping algorithm to clip to clip
polygon.
 We consider a polygon as a closed solid area. Hence after clipping it should remain
closed. To achieve this we require an algorithm that will generate additional line
segment which make the polygon as a closed area.
 The lines ab, cd, de, fg, gh, Ij are added to polygon description to make it closed.
SUTHERLAND – HODGEMAN POLYGON CLIPPING
 A polygon can be clipped by processing its boundary as a whole against each
window edge. This is achieved by processing all polygon vertices against each clip
rectangle boundary is turn.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 Beginning with the original set of polygon vertices, we could first clip the polygon
against the left rectangle boundary to produce a new sequence of vertices.
 The new set of vertices could then be successively passed to a right boundary
clipper, a top boundary clipper & a bottom boundary clipper as shown in fig.
 At each step a new set of polygon vertices is generated and passed to the next
window boundary clipper. This is the fundamental idea in the Sutherland Hodgeman
algorithm.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 The output algorithm is a list of polygon vertices all of which are on the visible side of
the clipping plane. This is achieved by processing 2 vertices of each edge of the
polygon around the clipping boundary or plane.
1. If the first vertex of the edge is outside, the window boundary and the second vertex
of the edge is inside then intersection point of the polygon edge with the window
boundary & the second vertex are added to the output vertex list.
[DIAGRAM]
2. If both the vertices of the edge are inside the window boundary, only the second
vertex is added to the output vertex list.
3.
4. If the 1
st
vertex of the edge is inside the window boundary and the second vertex of
the edge is outside, only the edge intersection with the window boundary is added to
the output vertex list.
5. If both the vertices of the edges are outside the window boundary nothing is added to
the output list.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 Once all the vertices are processed for one clip window boundary, the output list of
the vertices is clipped against the next window boundary.
 Going through the above 4 cases we can realize that there are two key processes in
this algorithm.
1. Determining the visibility of a point or vertex (Inside – Outside Text) &
2. Determining the intersection of the polygon edge and the clipping plane.
Sutherland Hodgeman Clipping Algorithm
1. Read coordinates of all vertices of the polygon.
2. Read coordinates of the clipping window.
3. Consider the left edge of the window.
4. Compare the vertices of each edge of the polygon, individually with the clipping
plane.
5. Save the resulting intersections & vertices in the new list of vertices according to 4
possible relationships between the edge and the clipping boundary.
6. Repeat the steps 4 & 5 for remaining edges of the clipping window. Each time the
resultant list of vertices is successively passed to process the next edge of the
clipping window.
7. Stop.
CURVE GENERATION TECHNIQUES
There are 2 approaches to draw curved lines.
1) The first approach lies the Curve Generation Algorithms line midpoint circle to
midpoint ellipse algorithm to draw curved lines.
In this case only true curves can be drawn.
2) In the second approach curved lines are approximated by a no of small straight line
segments with the help of interpolation techniques.
PROBLEMS IN TRUE CURVE GENERATION APROACH
1. To specify a curve we need more information than just endpoints.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
2. Using this approach only true curves like circular or elliptical are can be generated
and is not suitable for drawing other curves like wings or human faces.
INTERPOLATION TECHNIQUES
1. Lagrange’s Interpolation technique
2. Bezier generation technique
3. BSpline curve generation technique
In practice, we have to deal with some complex curves for which no direct mathematical
expression is available. Such curve can be drawn using approximation techniques.
]
 If we have a set of sample points of the unknown curve, then we can draw the
required curve by filling the region with known sample point by pieces of true curves
which pass through the sample points.
 The gap between the curve and rest of the sample points can be filling by calculation
coordinate values along the known curve and joining them by small straight line
segments as shown in the figure above.
1. LAGRANGE’S CURVE GENERATION TECHNIQUE
 The main task in this process is to find a suitable mathematical expression for the
known curve.
 There are polynomial, trignometric, exponential and other classes of function which
can be used to approximate the curve. But polynomial functions are preferred.
 Polynomial function in the parametric form is given as
x = f
x
(u)
y = f
y
(u)
z = f
z
(u)
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 We have to construct the function as sum of terms, one term for each sample point.
B
i
(u) is called the Blending function.
 For each value of parameter x the function B
i
(u) tells how much the current sample
point affects the curve. In other words each sample point tries to pull the curve in its
own direction and the function B
i
(u) gives the strength of the pull.
 In general the ith value of Blending function for other integer values is given as
 Using the Blending function, the expression for the curve passing through sample
points can be realised as:
x = x
1
B
1
(u) + x
2
B
2
(u) + x
3
B
3
(u) +      
y = y
1
B
1
(u) + y
2
B
2
(u) + y
3
B
3
(u) +      
z = z
1
B
1
(u) + z
2
B
2
(u) + z
3
B
3
(u) +      
2. BEZIER CURVE GENERATION TECHNIQUE
 This is the second approach for curve generation developed by French Engineer
Pierre Bezier.
 Bezier curve can be filled into any no. of control points.
 The degree of polynomial of the Bezier curve is determined by the no. of control
points.
 As a rule, the degree of polynomial of the Bezier curve is one less than the no. of
control points.
Ex. 3 points generate a parabola, 4 points generate a cubic polynomial.
¯
¯
¯
=
=
=
=
=
=
n
i
i i z
n
i
i i y
n
i
i i x
u B z u f
u B y u f
u B x u f
1
1
1
) ( ) (
) ( ) (
) ( ) (
) ( ) 1 ( 1 ) 3 )( 2 )( 1 (
)] ( [ )] 1 ( )][ 3 ( [ ) 1 ( ) 1 (
) (
n i i i i
n i u i u i u u u u
u B
i
÷ ÷ ÷ ÷ ÷ ÷ ÷ ÷ ÷ ÷
÷ ÷ ÷ ÷ ÷ ÷ ÷ ÷ ÷ ÷ ÷ ÷ +
=
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 Bezier curve has a no. of properties which makes it useful and convenient for curve
and surface design. It is widely used in CAD systems.
 We use the midpoint approach for Bezier Curve.
1) The lines joining the 4 connecting points (A, B, C, D) are determined (AB, BC, CD)
2) Then their midpoints (AB, BC, CD) are determined & connected by line segments.
3) Then their midpoints (ABC, BCD) are determined.
4) Finally, midpoints are connected and their midpoint ABCD is determined.
 The point ABCD, divides the Bezier curves into 2 sections. This makes point A, AB,
ABC & ABCD as the control points for first section and point ABCD, BCD, CD & D as
control points for second section.
 By considering the 2 sections separately, the curve is divided into 2 more sections,
thus we get 4 curves from the original Bezier Curve.
 This process can be repeated on the curve can be split into smaller sections until use
how sections so small that they can be replaced by straight lines.
3. BSPLINE CURVE GENERATION TECHNIQUE
 Spline is a tool made of thin flexible strip of metal or rubber used by draftsmen to aid
in drawing curved lines.
 The continuous curve of Bspline is defined by control points.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 While the curve is shaped by control points, it may or may not pass through all
control points.
 We can write a general expression for the calculation of coordinate position along a
B spline curve in a Blending function formulation as
Where
 P
k
÷ i/p set of n+1 control points.
 B
k
, d ÷ BSpline Blending function which is a polynomial of degree d – 1
 D can be any integer value between 2 & n + 1
 Blending functions for BSpline curves are defined by Can – De – Boor recursion
formula.
COMPUTER ANIMATION
Q. 1. What is Computer Animation?
Ans. It is defined as a time sequence of visual changes.
In addition to changes in position of object by translation, scaling & rotation, computer
generated animation can display time variations in object size, colour, texture, etc.
Computer animation can also be generated by changing the camera parameters such as
position, orientation & focal length.
Q. 2. What is segmentation?
Ans. Segmentation is the process in which the image related information present in the
display file is divided into segments.
¯
=
+ s s = =
n
k
k k
n d u d B P u P
0
1 2 ) ( ,
) ( 1 , ) ( 1 ,
1
) ( ,
1
1
u d B
u d u
u d u
u d B
u d u
u u
u d B
k
k k
k
k
k k
k
k
÷
÷ +
÷ +
+ ÷
÷ ÷ +
÷
=
+
+
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
7
INTRODUCTION TO 3D
3D Coordinate System –
The figure shows three dimensional cartesian
coordinate system. This is called as righthanded
system because righthand thumb points in
positive z direction. Most Graphics packages
utilises righthanded system. Another possible
arrangement is left handed system.
RightHand Coordinate System
 Put fingers around the z axis and the thumb
should point the positive direction of z axis.
Cylindrical –
In this system, vertical cylinder with
radius r is taken. The surface of the
constant z is horizontal plane which will
be parallel to xy plane. The surface of
constant u is a vertical plane which
contains z axis. Then x, y and z are
given as,
x = cos u, y = rsin u, z = z
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Spherical –
The surface of constant r is a sphere. The
surface of constant u is a vertical plane
which contains z axis. The surface with
constant o is a cone which is having apex
at origin.
From the diagram,
x = rcosusin o y = rsinusino z = rcosu
3D Display Techniques
To obtain a display of three dimensional scene, we must set a view plane or display
plane.
The object coordinates are transferred to the display
plane coordinates and are projected onto the display
plane.
Parallel Projection –
One method of generating a view of solid object is to project points on the object
surface along parallel lines onto the display planes. By selecting different viewing
positions, different visible points are mapped onto the display plane to obtain different two
dimensional views.
Let us take a 3D object and let us show the different two dimensional views on different
display planes.
The following diagram shows 3D object and its views from two different directions. The
diagram shows these directions and also the display planes.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Perspective Projection –
Another method for generating a view of three dimensional scene is to project points to
the display the plane along converging paths. In this method, the objects away from
viewing position are displayed smaller than the objects of some size which are near to
the viewing position.
In perspective projection, parallel lines in a scene are not parallel on the display plane.
This is more realistic, because that is how our eyes understands any scene.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Depth Cuing –
Knowing the depth information of the object is important, because from this information
we can decide which is front and which is back of the displayed object.
From diaa, it is difficult to decide whether the object is like diab or diac.
In depth wing, the lines which are closer to view position are displayed with more
intensity and lines away from view position are displayed with decreasing intensity. Depth
cuing can be applied by deciding maximum and minimum intensity values.
Visible line and Surface identification –
The visible lines and surfaces can be identified by the algorithms. There are different
methods to give 3D effects. Display visible lines in different color or highlight them. Draw
nonvisible lines as dashed lines or simply remove nonvisible lines. Applying shading to
visible surfaces, also gives the appearance of removal of hidden lines without actually
removing them.
Surface Rendering – Realistic images can be obtained by shading different surfaces with
different intensities. Using RayTracing, the shiny surfaces are displayed. The objects
can be shown as shiny, transparent by illuminating objects with different styles.
Cutway Views – The objects can be defined by hierarchical structures, so that, by cutting
the object into different pieces, the internal details of an object can be shown.
Viewing Pipeline –
The following figure shows the general steps to be followed for 3D viewing of the object.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 The conversion of modeling coordinates of the object into the world coordinate
system is referred as Modeling Transformation.
 Once the object is transferred into the world coordinates, it will be then transferred
into viewing coordinates. The process used to carry it out is referred as viewing
transformation. The viewing coordinate system is used as a reference for specifying
observer’s position.
 The viewing coordinates available in 3D coordinate system are to be projected on 3D
projection plane. The process is called as projection transformation.
 The projection coordinates, are finally mapped to device coordinates using
Workstation transformation.
The X
w
Y
w
Z
w
specifies the world coordinate system. The object to be viewed is as
shown.
The P
0
(X
0
, Y
0
, Z
0
) in the world coordinate system specifies the origin of the viewing
coordinate system X
v
Y
v
Z
v
.
Viewing Coordinates
Generating a view of an object in
three dimensions is similar to
photographing the object.
We can walk around the object and
take its picture from any angle, at
various distances and with camera
orientations.
Whatever appears in the viewfinder is
projected onto the flat film surface.
The size of the camera lens
determines which part of the object appear in the final picture. The ideas will be similar in
the 3D viewing system.
 A particular view of the object is selected by establishing the viewing coordinate
system. It is also called as view reference coordinate system. A view plane or
projection plane, is then set up perpendicular to the viewing Z
v
axis.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 A particular point P
0
(X
0
, Y
0
, Z
0
) in the world coordinate system is selected as origin
of viewing coordinate system. The point P
0
will then be nothing but the reference
point for viewing.
The object is then to be converted from world coordinate system to viewing
coordinate system, for projection.
Transformation from World Coordinates to Viewing Coordinates –
Before object details can be projected to the view plane, they must be transferred to
viewing coordinates. Conversion of object details from world to viewing coordinates is
equivalent to transformation that superimpose the viewing reference frame onto the world
frame.
This transformation will require sequence as,
1) Translate the view reference point to the origin of the world coordinate system.
2) 3D rotation required to coincide x
v
y
v
z
v
with x
w
y
w
z
w
.
3) All the back rotations required to bring x
v
y
v
z
v
at its original orientation.
4) Back translation to bring x
v
y
v
z
v
at its original position.
 The first step will require translation with T
x
= x
0
, T
y
= y
0
& T
z
= z
0
 The second step will require R
x
(x) followed by R
y
() as that of in 3D rotation (chap –
7).
 The third step will require R
y
() followed by R
x
(x) as that of in 3D rotation (chap –
7).
 The fourth step will require back translation with T
x
= x
0
, T
y
= y
0
& T
z
= Z
0
.
Projections – Once the world coordinates are converted into view coordinates then the
three dimensional object can be projected onto two dimensional plane (view plane).
There are two basic methods of projection.
a) Parallel Projection
b) Perspective Projection
Parallel Projection –
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
In parallel projection, coordinate positions are transformed to a view plane along the lines
which are parallel. A parallel projection can be defined with the projection vector V
p
which
defines direction of projection lines.
If projection vector is perpendicular to view plane, then the parallel projection achieved is
called as orthographic parallel projection.
If projection vector is not perpendicular to view plane, then
oblique parallel projection is achieved.
The transformation equations for orthographic parallel projection are simple. If the view
plane is placed at position Zv
p
along the Z
v
axis then (x, y, z) in viewing coordinates is
transformed to projection coordinates as,
x
p
= x y
p
= y z
p
= z
vp
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
However, original z coordinates are stored for depth information.
Oblique Parallel Projection –
In the diagram, x is the angle made by
projection vector from (x, y, z) to view plane.
The (x, y) is the point corresponding to (x, y, z)
if orthographic parallel projection would have
been done.
From the diagram,
x
p
= x + Lcos u
y
p
= y + Lsin u
Any parallel projection can be defined as,
When orthographic projection is done, o = y
0
0
=
1 00
0000
0100
1000
] 1 [ ] 1 [
p v
p p p
z
xyz z y x
sin
cos
tan
1
tan
1
.
tan
1
tan
1
1
1 1
zL y yp
zL x xp
whereL ZL Z L
Z
L
L
Z
and
+ =
+ =
= = =
= =
=
1 00
00 sin cos
0100
1000
] 1 [ ] 1 [
1 1
p v
p p p
Z
L L
xyz Z Y X
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 Perspective Projection – Following diagram shows the perspective projection from
projection reference point.
(The objects of same size at different distances from view planes produces different sizes
of projected images in perspective projection.)
To obtain perspective projection of three dimensional objects, we can transform points
along projection lines which meets project reference point Z
prp
along Z
v
axis and view
plane is placed at z
vp
.
The coordinate positions can be defined in
parametric equations along projection line.
x
1
= x – xu
y
1
= y – yu
z
1
= z – (zprp) u
The parameter u can take value from 0 to 1. When u = 0, then (x
1
, y1, z
1
) = (x, y, z)
whereas when u = 1 then (x
1
, y
1
, z
1
) = (0, 0, z
prp
). The projection reference point lies on zv
axis. On the view plane, u will be given as,
aphic fororthogr conditions z z y y x x
L
p p p
÷ = = =
= =
, ,
0
tan
1
1
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
By substituting this value into the equation of x
1
, y
1
& z
1
we get,
Thus projection point on the view plane can be calculated. The orthographic projections
are not affected by plane position because projection lines are parallel and are
perpendicular to view plane.
Oblique parallel projections are affected by position of view plane, because angle of
projection vector with view plane can change. The perspective projection is affected by
relative position of object and view plane.
Clipping and 3D viewing –
An algorithm for three dimensional clipping identifies and saves all surface segments
within a view volume, for display an output device. The parts which are outside the view
volume are discarded. Clipping in 3D is achieved by extending the ideas of two
dimensional clipping.
Instead of clipping against 2D window, clipping of object is done against the boundary
planes of the view volumes. Lines which are totally outside the volume boundary are
discarded. Lines which are completely inside the selected volume boundary, are
selected. Lines which are partially inside are intersected with the volume boundary
planes and the part which is inside the volume boundary is displayed.
Z z
Z z
u
prp
vp
÷
÷
=
vp p
prp
vp prp
p
prp
vp prp
p
prp
vp prp
prp
vp
p
z z
and
z z
z z
y y
Similarly
z z
z z
x x
z z
z z z z
x
z z
z z
x x x x
=
÷
÷
=
÷
÷
=
÷
+ ÷ ÷
=
÷
÷
÷ = =
.
,
.
1
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Normalized view volumes for clipping & viewport clipping –
The rectangular parallelopiped in world coordinate system is mapped into the unit cube,
which is normalized view volume.
The normalized view volume is a region defined by the planes x = 0, x = 1, y = 0, z = 0, z
= 1.
The objects in the view volume in world coordinates are transformed to unit cube (volume
viewport).
The factors D
x
, D
y
and D
z
are the ratios of the viewport and regular window view volume.
x
v
= x
vmin
+ (x
w
_x
wmin
) Dx
y
v
= yvmin + (y
w
y
wmin
) Dy
z
v
= z
vmin
+ (z
w
z
wmin
) Dz
(extension of 2D window to viewport clipping).
Lines and polygons in a scene are clipped against viewport boundaries with procedures
similar to two dimensions. The objects are now processed against planes instead of lines.
) 1 , 1 , 1 ( ) , , (
) 0 , 0 , 0 ( ) , , (
max max max
min min min
min max
min max
min max
min max
min max
min max
=
=
÷
÷
=
÷
÷
=
÷
÷
=
v v v
v v v
w w
v v
z
w w
v v
y
w w
v v
x
z y x
z y x where
z z
z z
D
y y
y y
D
x x
x x
D
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
The two dimensional concept of region codes can be extended to three dimensions.
Instead of 4 bit code, code of 6 bits will be developed. One bit for front of the unit volume
and one bit for the back of the unit volume. For each endpoint of the line the 6 bit code
will be developed.
The bits are as follows,
bit
0
= 1 if x < x
vmin
(left)
bit
1
= 1 if x > x
vmax
(right)
bit
2
= 1 if y < y
vmin
(below)
bit
3
= 1 if y > y
vmax
(above)
bit
4
= 1 if z < z
vmin
(back)
bit
5
= 1 if z > z
vmax
(front)
 If the endpoint is inside the clipping volume, then the code will be 000000.
 If both the endpoints has the codes as 000000, then the line is selected for display.
 If there is 1 at the same position in the two codes then the line is completely outside
the view volume and hence rejected.
 If the above conditions are not satisfied then the line is intersected with necessary
planes out of the 6 planes of the view volume.
 After intersection, the part of the line outside the view volume is discarded.
To find intersection of a line we will; use parametric equations. In LiangBarshy algorithm,
any point (x, y, z) is specified in parametric equation form as follows.
x = x
1
+ (x
2
– x
1
)u
y = y
1
+ (y
2
– y
1
)u 0 s u s 1
z = z
1
+ (z
2
– z
1
)u
Let us consider a case in which line is to be intersected with a plane say z = z
vmin
.
Then the value u is found as
If the value of u is not in the range of 0 s u s 1 then it means line is not intersecting with
the plane z = z
vmin
.
If value of u is between 0 and 1 then there exists intersection and intersecting point will
be given as follows.
1 2
1 min
z z
z z
u
v
÷
÷
=
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 Similarly, intersections with remaining 5 planes can also be determined.
.
) (
) (
min
1 2
1 min
1 2 1
1 2
1 min
1 2 1
v
v
v
z z
z z
z z
y y y y
z z
z z
x x x x
=


.

\

÷
÷
÷ + =


.

\

÷
÷
÷ + =
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
8
VISIBILITY Z BUFFER ALGORITHM
While generating realistic graphics display, it is important to identify visible and invisible
parts of the scene. The algorithms used to identify this are called as visible surface
detection methods or hiddensurface elimination methods.
Visible surface detection algorithms are broadly classified according to the way of
working. The two different approaches are objectspace methods or imagespace
methods.
An objectspace method compares the objects and parts of the object with each other
within the scene definition, to determine visible surfaces.
In an imagespace method, visibility is decided pixel by pixel at each position on the
projection plane. Most of the algorithms are of imagespace methods.
Plane equations –
In 3D applications, such as surface rendering, transformation, visible surface detection, it
is necessary to know plane equations.
The equation of the plane surface is given by,
A
x
+ B
y
+ C
z
+ D = 0
Where, (x, y, z) is any point on the plane. To know the above equation of the plane, we
must know A, B, C and D.
Let us take three points, (x
1
, y
1
, z
1
), (x
2
, y
2
, z
2
) and (x
3
, y
3
, z
3
) on the plane. These three
points will form simultaneous equations as,
Ax
1
+ By
1
+ Cz
1
+ D = 0
Ax
2
+ By
2
+ Cz
2
+ D = 0
Ax
3
+ By
3
+ Cz
3
+ D = 0
In the above equations, A, B, C and D are unknown. Let us rearrange the equations as,
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
For any point, not on the plane with parameters A, B, C,
D, we have Ax + By + Cz + D = 0
We can identify the point as either inside the plane or
outside the plane, accordint to sign.
If Ax + By + Cz + C < 0, the point (x, y, z) is inside the
surface
If Ax + By + Cz + D > 0, the point (x, y, z) is outside the
surface
These inequality tests are valid in righthanded cartesian system, provided the plane
parameters A, B, C and D are calculated using vertices selected in anticlockwise order,
when viewing the surface in an outsidetoinside direction.
BACKFACE Detection –
This is a fast and simple object space method which is used for identifying the back faces
of the object. This method is based on the equation of the plane.
In righthanded coordinate system, of (x
1
, y1, z
1
) is “inside” the given plane then,
Ax
1
+ By
1
+ Cz
1
+ D < 0
3 3 3
2 2 2
1 1 1
3 3
2 2
1 1
3 3
2 2
1
1
3 3
2 2
1 1
3 3 3
2 2 2
1 1 1
3 3
2 2
1 1
3 3 3
2 2 2
1 1 1
3 3
2 2
1 1
3 3 3
2 2 2
1 1 1
3 3
2 2
1 1
3 3 3
2 2 2
1 1 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
z y x
z y x
z y x
D
y x
y x
y x
C
z x
z x
z x
B
z y
z y
z y
A
z y x
z y x
z y x
y x
y x
y x
D
C
z y x
z y x
z y x
z x
z x
z x
D
B
z y x
z y x
z y x
z y
z y
z y
D
A
z
D
C
y
D
B
x
D
A
z
D
C
y
D
B
x
D
A
z
D
c
y
D
B
x
D
A
÷ = = = =
÷
÷
÷
=
÷
÷
÷
=
÷
÷
÷
=
÷ =

.

\

+

.

\

+

.

\

÷ = 
.

\

+ 
.

\

+ 
.

\

÷ = 
.

\

+ 
.

\

+ 
.

\

pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
The equation of the plane is determined by taking three points on the plane in
anticlockwise direction when looking from “outside” to “inside”.
Consider the following diagram,
In right handed system, if viewing direction is along ‘‘ve Z
v
axis, then C is the component
of normal to the surface which will be parallel to Z axis. if c < 0 then the Normal Vector
points away from view position, and hence it will be decided as back surface / back face.
In the above diagram, component C
1
of N
1
will be negative whereas component C2 of N
2
will be positive and hence surface with normal N
1
is a backface and hence it is to be
removed while displaying. The surface with normal N2 is considered to be frontface and
hence it is to be displayed.
DepthBuffer (zbuffer) method –
The depth buffer method is commonly used imagespace method, used to detect the
visible surfaces. In this method, surface depths are compared at each pixel position on
the projection plane. This method is called as zbuffer method. This is because, usually,
he depth is measured from view plane along zaxis. Each surface of a scene is
processed separately, one point at a time across the surface.
Each point (x, y, z) on the surface
is converted to projection
coordinates (x, y) as shown in the
diagram. For every pixel (x, y) on
the view plane, object depths can
be compared by comparing z
values. The point with lowest
depth will be selected for display.
For this algorithm, two buffer
areas are required. One is used to
store depth values for each (x, y)
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
position and refresh buffer is used to store intensity values/color values for color systems
for each (x, y) position.
All the positions of the depth buffer are initialized with 1 and all the positions of the
refresh buffer are initialized with background intensity.
The steps of depthbuffer can be written as follows.
1. Initialize the depth buffer and refresh buffer so that for all the positions (x, y) on the
view plane,
depth (x, y) = 1 and refresh (x, y) = I
background
2. For each position on each surface, compare depth values to previously stored values
in the depth buffer to determine visibility.
 Calculate the z value for each (x, y) position on the surface.
 If z < depth (x, y) Then set depth (x, y) ÷ z and
Set refresh (x, y) ÷ I
surf
(x, y)
Where, I
background
is background intensity.
I
surf
(x, y) is intensity of a point (x, y) on the surface. After all the surfaces have been
processed, the depth buffer contains the corresponding depth values for visible surfaces
and refresh buffer contains the corresponding intensity values for these surfaces.
Depth values for a position (x, y) are calculated from plane equation for each surface.
If the depth of position (x, y) has been determined to be z, then the depth z
1
of the next
position along the same scan line i.e. (x+1, y) is obtained as,
Similarly, depth values for succeeding scan lines can be obtained as follows,
C
D By Ax
Z
÷ ÷ ÷
=
C
A
z z
C
A
C
D By Ax
C
D By x A
z
÷ =
÷
÷ ÷ ÷
=
÷ ÷ + ÷
=
1
1
) 1 (
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Thus, successive values of depth on a particular surface can be calculated faster.
C
B
z z
C
B
C
D By Ax
z
C
D y B Ax
z
+ =
+
÷ ÷ ÷
=
÷ ÷ ÷ ÷
÷
11
11
11
) 1 (
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
9
COMPUTER ANIMATION
Computer Animations, design of animation sequence, Raster animations, morphing
motion specification, kinematics & dynamics.
The term computer animation generally refers to any time sequence of visual changes in
a scene.
In addition to changing object position with translations or rotations, a computer
generated animation could display time variations in object size, colour, texture etc.
Computer animations can also be generated by changing camera parameters such as
position, orientation and focal length.
Segmentation:
In practice, the image on the display screen is often composed of several pictures or
items of information.
E.g. We may wish to display an internal plan of the lining room. The plan may contain
various objects such as sofa set, T.V., showcase etc. each object has a set of attributes
such as size, colour & its position in the room.
We know that all the information about the image is stored in the display file. The display
file is divided into segments. Each segment corresponds to a component or object of the
overall display & it is associated with a set of attributes. Along with the attributes, the
segment is also associated with image transformation parameters such as scaling,
rotation, shear transformation etc.
The most common screen attributes of an object are shape, size, colour, position,
visibility etc. by setting the visible attribute of the segment, we can decide whether to
display or not.
When the visible attribute is set to 1, it is included in the active segment list & display file
interpreter processes it. Such a segment is called posted segment.
When the visible attribute of segment is D it is not included in the active segment list &
display file interpreter ships this segment. Such a segment is called unposted segment.
Design of an Animation Sequence
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
In general, an animation sequence is designed with the help of the following steps –
 Storyboard layout
 Object definition
 Keyframe specification
 Generation of inbetween frames
Definition of frame :
For framebyframe animation, each frame of the scene is separately generated and
stored later, the frames can be recorded on a film or they can be consecutively displayed
in “realtime playback” mode.
÷ The storyboard is an outline of the action. It defines the motion sequence as a set of
basic events that are to take place. Depending on the type of animation to be produced,
the storyboard would consist of a set of rough sketches or it could be a list of the basic
ideas for the motion.
÷ An object definition is given to each participant in the action. Objects can be defined in
terms of basic shapes such as polygons, circles, arc, spheres etc. In addition, the
associated movements of each object are specified along with the shape.
÷ A key frame is a detailed drawing of a scene at a certain time in the animation
sequence. Within each key frame, each object is positioned according to time for that
frame. More key frames are specified for complex motion than simple, slowly varying
motion.
÷ Inbetween frames are file intermediate frames between the key frames. The number
of inbetween frames needed is determined by the media to be used to display the
animation. Film requires 24frames per second and graphic sequences are refreshed at
the rate of 30 to 60 frames per second. Typically, time intervals for motion are set up so
that there are from 3 to 5 in between frames for each pair of key frames.
Raster Animations :
On raster systems, we can generate realtime animations in limited applications using
raster operations. Raster systems store picture information as pixel patterns in the frame
buffer. Therefore, some simple transformations can be carried out rapidly by simply
moving rectangular arrays of stored pixel values from one location to another within the
frame buffer.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Translating an object from screen position (a) to position (b) by moving a rectangular
block of pixel values. Coordinate positions P
min
& P
max
specify the limits of the rectangular
block to be moved & P
0
is the destination reference position.
Figure above illustrates translation performer as a block transfer of a raster area. The bit
setting in a rectangular area are copied as a block into another part of the raster. We
accomplish this translation by false reading pixel intensities from a specified rectangular
area of a raster into an array, then we copy the array back into the raster at the new
location. The original object could be erased by filling its rectangular area with
background intensities.
Morphing :
Transformations of object shapes from one form to another is called morphing which is a
shortened form of metamorphosis. Morphing methods could be applied to any motion or
transition involving change of shape.
Given the key frames for an object transformation, we first adjust the object specification
in one of the frames so that the no. of polygon edges (or the no. of vertices) is same for
both frames.
An edge with vertex positions 1 & 2 in key frame K evolves into two connected edges in
key frame K+1.
for manufacturing a line segment in key frame k into two connected line segment
in key frame k+1.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Linear interpolation for transforming a triangle into a quadrilateral.
A straight line segment in key frame k is transformed into two line segments in key frame
k+1. Since key frame k+1 has an extra vertex, we add a vertex between vertices 1 & 2 in
key frame k to balance the no. of vertices (& edges) in the two key frames.
We can state general processing rules for equalizing key frames in terms of either the no.
of edges or the no. of vertices to be added to a key frame.
Rules for edges
Let L
k
& Lk+1 denote line segments in consecutive frames.
1) L
max
= max (L
k
, L
k+1
)
L
min
= min (L
k
, L
k+1
)
2) N
e
= L
max
mod L
min
3) N
e
= int (L
max
/L
min
)
Where N
e
denotes the no. of edges to be divided.
N
s
denotes the no. of sections.
4) The preprocessing is accomplished by dividing N
e
(no. of edges) to N
s+1
sections.
Rules for vertices :
Let V
k
& V
k+1
denote the no. of vertices in the two consecutive frames.
1) V
max
= max (V
k
, V
k+1
)
V
min
= min (V
k
, V
k+1
)
2) N
es
= (V
max
– 1) mod (V
min
– 1)
N
es
÷ no. of line sections
3) N
p
= int (V
max
1/V
min
1)
N
p
÷ no. of points to be added.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
4) Preprocessing using vertex count is performed by adding the no. of points to the no.
of line sections.
Motion specifications:
There are several ways in which the motions of objects can be specified in an animation
system.
1) Motion specifications can be given in terms of translation & rotation parameters i.e.
we specify the rotation angles & translation vectors. Then the geometric
transformation matrices are applied to transform coordinate positions.
2) We can use an approximating equation to specify certain kinds of motions.
Eg. We can approximate the path of a bouncing ball with damped rectified line curve.
y(x) = A  sin (w
x
+u
0
)  e
where A ÷ initial complitude
w ÷ angular frequency
u
0
÷ phase angle
k ÷ damping constant
These methods can be used for simple user programmed animation sequences.
3) We can also construct animation sequences using kinematic or dynamic descriptions.
With a kinematic description, we specify the animation by giving motion parameters
(position, velocity & acceleration) without reference to the forces that cause the
motion.
Dynamic descriptions on the other hand require the specification of the forces that
produce the velocities & accelerations. Examples of forces affecting object motion include
electromagnetic, gravitational, friction & other mechanical forces.
Visibility:
In a given set of 3D objects & viewing specifications, we wish to determine which lines or
surfaces of the object are visible, so that we can display only the visible lines or surfaces.
This process is known as hidden surface or hidden line elimination or visible surface
determination.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
Various algorithms are used to find the hidden lines or surface & visible lines or surfaces
to an observer located at a specified point in space. Eg. Backface removal algorithm, Z
buffer algorithm, warnockls algorithm etc.
Depth Buffer algorithm:
÷ One of the simplest & commonly used image space approach to eliminate hidden
surface is the Zbuffer or depth buffer algorithm.
÷ This algorithm compares the surface depths at each pixel position on the projection
plane.
÷ The surface depths is measured from the new plane along the Z axis of a viewing
system.
÷ When the object description is converted to projection coordinates (x, y, z), each pixel
position on the view plane is specified by x & y coordinate & z value gives the depth
information.
÷ Thus object depths can be compared by comparing the zvalues & hence the name z
buffer algorithm.
÷ The implementation requires another buffer memory called zbuffer along with the
frame buffer memory required for raster display devices.
÷ The zbuffer is used to store depth values for each (x, y) position as surfaces are
processed & frame buffer stores the intensity values for each position.
÷ Initially, all positions in the depthbuffer are set to D (minimum depth) & the refresh
buffer (frame buffer) is initialized to the background intensity.
÷ Each surface listed in the polygon tables is then processed, one scan line at a time,
calculating the depth (z value) at each (x, y) pixel position.
÷ The calculated depth is compared to the value previously stored in the depth buffer at
that position. if the calculated depth is greater than the value stored in the depth buffer,
the new depth value is stored, & the surface intensity at that position is determined &
placed in the same xy location in frame buffer.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
10
GRAPHICS COMMANDS
Note: The output screen is initially set with background colour while & the drawing color
(set color) is set to black.
1. putpixel ( );
 Putpixel plots a pixel in the specified color at a specified point.
 Syntax :
putpixel (int x, int y, int color);
 eg:
putpixel (300, 400m, 4);
2. line ( );
 line draws a line between two specified points.
 Syntax:
line (int x
1
, int y
1
, int x
2
, int y
2
);
 Eg :
line (100, 100, 100, 200);
3. set line style ( );
 Set line style sets the current line style and width or pattern.
 Syntax :
setlinestyle (int linestyle, unsigned pattern, int thickness);
 eg :
setlinestyle (3, 1, 1)
line (100, 100, 100, 200);
4. bar ( );
 bar draws a filled in rectangular, two dimensional bar.
 Syntax :
bar (int left, int top, int right, int bottom);
Parameters Meanings
left, top Rectangle’s upper left corner
right, bottom Rectangle’s lower right corner
 Eg :
Bar (200, 200, 300, 300);
5. rectangle ( );
 Draw a rectangle in current line style, thickness & drawing color.
 Syntax :
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
rectangle (int left, int top, int right, int bottom);
 eg :
rectangle (100, 100, 200, 300)
6. circle ( );
 Draw a circle in current drawing color.
 Syntax:
circle (int x, int y, int radius);
Parameters Meanings
x, y centre coordinates
 eg :
circle (400, 400, 20);
7. ellipse ( );
 ellipse draws an elliptical arc.
 Syntax:
ellipse (int x, int y, int stangle, int endangle,
int x radius, int y radius);
Parameter Meaning
x, y center of ellipse
x radius Horizontal axis
y radius Vertical axis
stangle Starting angle
endangle Ending angle
 Eg:
Ellipse (500, 200, 0, 300, 50, 20);
8. fillellipse ( );
 Draw an ellipse, then fills the ellipse with the current fill pattern.
 fillellipse (int x, int y, int x radius, int y radious);
 eg:
fillellipse (500, 200, 0, 360, 50, 20);
9. arc ( );
 Draws a circular arc in the current drawing color
 Syntax :
arc (int x, int y, int stangle, int endangle, int radius);
 eg:
arc (100, 100, 300, 270, 40);
10. pieslice ( );
 Draws a pieslice in the current drawing color, then fills it using the current fill pattern
& fill colour.
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
 Syhntax :
pieslice (int x, int y, int stangle, int endangle, int radius);
 eg :
pieslice (400, 200, 270, 360, 50);
11. floodfill ( );
 The area bounded by the color border is flooded with the current file pattern & fill
color.
 Syntax:
floodfill (int x, unt y, int border);
 eg :
circle (400, 400, 20);
floodfill (400, 400, 14);
12. set fillstyle ( );
 Sets the current fill pattern & fill color
 Syntax:
setfillstyle (int pattern, int color);
 eg:
setfillstyle (1, 4)
circle (400, 400, 20);
13. set color ( );
 setcolor sets the current drawing color.
 Syntax :
setcolor (int color);
 eg:
setcolor (4);
circle (400, 400, 20);
14. setbkcolor ( );
 Set the background color to the specified color.
 Syntax:
setbkcolor (int color);
 eg:
setbkcolor (4);
15. Outtext xy ( );
 Display a text string in the viewport at the position (x, y)
 Syntax:
outtext xy (int x, int y, char text string);
 eg: outtext xy (200, 300, “CONGRAGULATIONS”);
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
16. settextstyle ( );
 Sets the text font, direction in which text is displayed and
the size of the character
 Syntax :
settextstyle (int font, int direction, int char size);
 eg settextstyle (1, 1, 3);
outtextxy (200, 300, “CONGRATS”);
pdf Machi ne
A pdf w r i t er t hat pr oduces qual i t y PDF f i l es w i t h ease!
Produce qualit y PDF files in seconds and preserve t he int egrit y of your original document s. Compat ible across
nearly all Windows plat forms, simply open t he document you want t o convert, click “print”, select the
“Broadgun pdfMachine print er” and t hat ’s it ! Get yours now!
1
* INTRODUCTION TO COMPUTER GRAPHICS *
INTRODUCTION What is Graphics? Elements of a Graphics work station. Video display devices – Random Scan System & Raster Scan System, Input devices – Graphics Software, coordinate representation, fundamental problems in Geometry. Computer Graphics Computer Graphics is the pictorial representation of information using a computer program. In Computer Graphics, pictures as graphical subjects are represented as a collection of discrete picture element called pixels. Pixel is smallest addressable screen element.
Pixel Column P1 & P2 are represented as one pixel (4, 3) The process of determining the appropriate pixels for representing pictures or object is Rasterization & the process of representing continuous pictures as graphical object as a collection of discrete pixel is called Scan Conversion. Applications:Some of the areas of applications of computer graphics is CAD (Computer Aided Design). This is issued by civil, mechanical, algbrical & electronic engineers to build a model of building, bridges, PCB circuit, etc.
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
They can also be used for developing a model of bridge & various effect and stimulate the situation in Developing a model of a bridge and testing it over a simulator for earthquake resistance. Medical Imaging – It can be used to train new doctors on understanding and experimenting surgery. It is used in molecular biology to study the biological model in genes.
CATHODE RAY TUBE (CRT) Simplified representation of CRT:
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
simply open the document you want to convert.e. Compatible across nearly all Windows platforms. The phosphor then emits a small spot of light at every position contacted by the electron beam. Since light emitted by the phosphor fades very quickly some method is needed for maintaining the screen picture. it passes through focusing and deflection systems that direct the beam towards the specified position on the phosphor screen. This type of display is called Refresh CRT. click “print”. Primary components of CRT are as follows:1 HEATER ELEMENT AND CATHODE pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . cathode rays) is emitted by the electron gun. One of the simplest way to maintain pictures on the screen is to redraw the image rapidly.BASIC OPERATION A beam of electrons (i.
Compatible across nearly all Windows platforms. a CRT has the electron beam directed only to the parts of the screen where a picture is to be drawn. Electrostatic focusing is commonly used in television and computer graphics monitor. 3 ACCELERATING ANODE They are positively charged anodes who accelerate the electrons towards phosphor screen. It almost covers cathode leaving small opening for electrons to come out. 5 PHOSPHOR COATING When the accelerating electron beam (collides) is incident on the phosphor cooling. A smaller negative voltage on the control grid will simply decrease the number of electrons passing through.e. 4 FOCUSING & DEFLECTION COILS They are together needed to force the electron beam to converge into a small spot as it strikes the screen otherwise the electrons would repel each other and the beam would spread out as it approaches the screen. When the electrons in the beam collide with the phosphor coating they are stopped and their kinetic energy is absorbed by the phosphor. Intensity of the electron beam is controlled by setting voltage levels on the control grid. Cathode is cylindrical metallic structure which is rich in electrons. 2 CONTROL GRID It is the next element which follows cathode. A high negative cottage applied to the control grid will shut off the beam by repelling electrons and stopping them from passing through the small hole at the end of control grid structure.Heat is supplied to the cathode by passing current through heater element. click “print”. Thus we can control the brightness of a display by varying the voltage on the control grid. A B pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. simply open the document you want to convert. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . Random scan monitors draw a picture one line at a time and for this reason are also known as Vector Scan Displays. There are two techniques for producing images on the CRT screen 1 Vector Scan / Random scan Display 2 Raster Scan display 1 VECTOR / RANDOM SCAN DISPLAY Vector scan display directly traces out only the desired lines on the CRT tube i. On heating the electrons are released from cathode surface. a part of Kinetic Energy is converted into light and heat.
It is an interface between the graphics representation in the display file and display device. we can blank the beam as we move it. The program which converts these commands into actual picture is called the Display file Interpreter. move cursors. etc and the operands provide the coordinate of a point to process the commands. an operation code (opcode) and operands. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.If we want a line connecting point A with B on the vector graphics display. The display processor is connected to the display device. processes and manages the display process. The commands present in the display file contains two fields. Compatible across nearly all Windows platforms. Opcode identifies the commands such as line draw. The graphic commands is the program and translated by the graphics package and stored in the display file. we simply drive the beam deflection circuiting. click “print”. If we want to move the beam from point A to point B without showing a line between points. which will cause the beam to go directly from point A to B. In other records the file used to store the commands necessary for drawing the line segments is called the Display file. simply open the document you want to convert. INTERNATIONAL OPERATION An application program along with graphics package is present in the system memory. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
30) 0 (50.55) pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 30 Draws line between points (70.80) Command 5: 2. 55) and current cursor position (40. 30) (30 . 55) (40. 60. 30) & (50. 80) (30. click “print”. 80) Command 2: 2. 80) (30.30) (50. e. one for xcoordinate and one for ycoordinate of the operand.80) Command 4” 1. Compatible across nearly all Windows platforms.g. 30. simply open the document you want to convert.30) (30. 40.30) (50. 50. 70. 80) Command 3: 2.One of the way to store opcode and operands of series of commands is to use to separate arrays. 55 It makes current cursor position to point (40. COMMAND MOVE LINE OPCODE 1 2 The figure below shows how these commands are interpreted and plotted. 55) (30.30) (70. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 55 It draws the line between point (60. one for opcode. 80 Draws line between point (30. 30) & (50. 30 Moves the current cursor position to point (30.50) (60. Command 1: 1. 30) (50. It is also necessary to assign meanings to the possible opcodes before we can proceed to interpret them.
Compatible across nearly all Windows platforms. INTERNAL OPERATION Fig PROCESS – RASTER SCAN SYSTEM Picture definition is stored in a memory area called Refresh buffer or Frame Buffer for which a fined area of the system memory is kept reserved. Here the beam is swept back and forth from left to right across the screen. In the Raster Scan display the screen image is maintained by repeating scanning of the same image.30) RASTER SCAN DISPLAY This is the most common method of drawing images on the CRT screen. When the beam is moved from left to right it is ON. This is called the Vertical Retrace. the electron beam is swept across the screen one row at a time from top to bottom.(30. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . When the beam reaches the bottom of the screen it is turned off and is rapidly retraced back to the top to start again. simply open the document you want to convert. click “print”. The process is shown as Refreshing of screen.e.30) (70. Horizontal and vertical deflection signals are generated to move the beam all over the screen in a pattern as shown in figure i. The frame buffer holds the set pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. In this method. The beam is OFF when it moves from right to left and is called as Horizontal Retrace and is shown by dotted lines.
g. combination of red and green light are emitted and two additional colours orange and yellow are displayed. the screen coordinates are taken as positive (x. Distinguish between Raster & Random Scan RASTER SCAN DISPLAY i) It draws the image by scanning one row at a time RANDOM SCAN DISPLAY i) It draws the image by directing the electron beam directly to the part of the screen where the image is to be drawn. It is responsible for retrieving data from the frame buffer and passing it to the display device. ii) iii) Lines are jaggered and curves are less smoother iii) Line plots are straight and curves are smooth. Stored intensity values are then retrieved from the refresh buffer and displayed on the screen one row at a time. The displayed colour depends on how far the electron beam penetrates into the phosphor layers. iv) They are more suited to geometric iv) They are more suited to line area drawing applications e. At intermediate beam speeds. Tele vision . pen plotter. Shadow – Mask technique BEAM PENETRATION TECHNIQUE This technique is used in Random Scan Monitors. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Beam Penetration technique B. drawing application e. The outer layer is of red phosphor and inner layer is of green phosphor.of intensity values for all the screen points. Generally. usually red & green. The beam acceleration voltage controls the speed of the electrons and hence the screen colour at any point on the screen. click “print”. Hence the screen is continuously refreshed by scanning from maximum value of ycoordinate down to y = 0. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . simply open the document you want to convert. A beam of slow electrons excites only the outer red layer. the inside of CRT is coated with two layers of phosphor.g. A. They have higher resolution than Raster Scan System ii) They generally have resolution limited to pixel size. In this technique. Video controller has direct access to memory locations in the frame buffer. CRO’s monitors. COLOUR DISPLAYS There are 2 methods for producing colour displays. Frame buffer maps the screen into cartesian coordinates. Compatible across nearly all Windows platforms. y) plane. A beam of fast electrons penetrates the outer red layer and excites the inner green layer.
Compatible across nearly all Windows platforms. the three electron beams are deflected and focused as a group onto the shadow mask and when they pass through a hole onto a shadow mask they excite a dot triangle. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. click “print”. As shown in figure. another emits a green light and the third one emits a blue light. By varying the intensity of the three electron beams we can obtain different colours in the shadow mask CRT. The CRT has three electron guns one for each dot. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . A dot triangle when activated appears as a small dot on the screen which has colour combination of three small dots in the dot triangle. A dot triangle consists of 3 small phosphor dots of red. In shadow mask technique. These phosphor dots are arranged so that each electron beam can activate only its corresponding colour dot when it passes through the shadow mask. simply open the document you want to convert. the CRT screen has three phosphor colour dots at each pixel position. Fig SHADOW MASK TECHNIQUE The shadow mask grid consists of series of holes aligned with the phosphor dot patterns.V. green and blue colour.SHADOW MASK TECHNIQUE The shadow mask technique produces a much wider range of colours than the beam penetration technique. a shadow mask grid just behind the phosphor coated screen. One phosphor dot emitts red light. Hence this technique is commonly used in raster scan displays including colour T.
the keyboard controller places a code corresponding to the key pressed. click “print”. This code is called the scan code. in a part of its memory called keyboard buffer. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . It is used for entering text and numbers.* INPUT DEVICES * Following are the commonly used input devices 1 Keyboard 2 Mouse 3 Scanner 4 Trackball / Spaceball 5 Joystick 6 Digitizer / Graphical tablet 1 KEYBOARD Keyboard is the primary input device for any graphics system. The standard keyboard consists of 1 Alphanumeric keys 2 Function keys 3 Modifier keys 4 Cursor Movement keys 5 Numeric Keypad Fig KEYBOARD PROCESS When we press a key on the keyboard. The CPU then reads the scan code from the Keyboard Buffer. shapes & styles. Compatible across nearly all Windows platforms. simply open the document you want to convert. The keyboard controller informs the CPU of the computer about the key pressed with the help of interrept signals. Keyboards are available in various sizes. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.
It consists of strain gauges which measures the amount of pressure applied to the spaceball to provide input for spatial positioning & orientation of the ball is pushed a pulled in various directions. Nowadays mouse consists of one more wheel on top to scroll the screen pages. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 3 TRACL BALL & SPACEBALL Fig TRACKBALL A trackball is a ball that can be rotated with the finger or palm of the hand to produce the screen cursor movement. the spaceball is used for 3D positioning & selection of operation in virtual reality system unlike the trackball the spaceball does not actually move.2 MOUSE A mouse is a palm sized box used to position the screen cursor. click “print”. Compatible across nearly all Windows platforms. graphics. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . One. It consists of a ball on the bottom connected to wheels to provide the amount and direction of movement. two or three buttons are usually included on the top of the mouse for signaling the execution of same operation. photos as text available in the printed form for computer processing. 4 SCANNER Scanner have become an important part of the home. While the trackball is used for 2D positioning. simply open the document you want to convert. It is a device which can be used to store drawings. Potentiometers attached to the ball measure the amount and direction of rotation. office over the last few years.
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. simply open the document you want to convert. The left or right movement is indicated by other one potentiometer & the forward or backward movement is indicated by other potentiometer. As the drum rotates the light source slowly moves from one end to the other. Thus with a joystick box x & y coordinate positions can be simultaneously altered by the motion of a single lever. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . click “print”. Moving the liver changes the settings on the potentiometer. Some joysticks may return to this zero (centre) positions when released. A finely collimated light beam is directed at the photo. thus doing a raster scan of the inter photograph. Joysticks are inexpressive and quiet commonly used where only rough positioning is needed. and the amount of light reflected is measured by a photocell. 5 JOYSTICK Fig (A) JOYSTICK (B) CIRCUIT DETAILS A joystick has a small vertical lever mounted on the base and used to steer the screen cursor around.Fig PHOTO SCANNER As shown in the fig the photograph is mounted on a rotating drum. Compatible across nearly all Windows platforms. It consists of two potentiometers attached to a single liver.
ranging in size from about 6 x 6 inches upto 48 to 72 inches or more. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Electromagnetic signals generated by electrical pulses applied in sequence to the wires in the grid induce an electrical signal in a wire cod in the styles. Compatible across nearly all Windows platforms. The strength of the signal induced by each pulse is used to determine the position of the styles. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . click “print”. simply open the document you want to convert. which can direct the position of a movable styles. In this arrangement a grid of wires of ¼ to ½ inch centers is embedded in the tablet surface.6 DIGITIZER / GRAPHICAL TABLET For applications such as tracing we need a device called a Digitizer or Graphical Tablet. It consists of a flat surface.
Compatible across nearly all Windows platforms. Presentian’s algorithm. DTA algorithm. outside text. characters generation attributes of lines. the values for rent x & y can be obtained as follows xi+1 = xi + x x & i 1 x i y y x y i 2 2 y x 2 2 x y 1 1 y y x 1 1 3 x 4 i 1 The eqns 3 & 4 are called as the recursive eqns for finding out the successive values of x & y along a required line. filling character.. DDA ALGORITHM [DIGITAL DIFFERENTIAL ALGORITHM] The slope of a straight line is given as m y y 2 y1 1 n x 2 x1 The above differential Eqn. Boundary fill algo. frame buffers. flood fill algo. midpoint ellipse algo. scan. curves. midpoint circle alg. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . file of curved boundary areas. etc. click “print”.2 LINE DRAWING ALGORITHM ALGORITHMS Line drawing algorithm. line. Circle & ellipse generating algo. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Polynomial & spline curves – inside. Such a way of rasterising a line is called Digital Differential Algorithm. Can be written as y y x 2 2 y1 x x1 x y 2 2 & n x1 y y1 2 Once the intervals are known. simply open the document you want to convert.
x = 1. y = 1. click “print”. y2) such that they are not equal 2 x =  x2 – x1  & y =  y2 – y1  3 If x y. then length = x. then x = 1 else y = 1 If.If  x   y . Compatible across nearly all Windows platforms. simply open the document you want to convert. then y x i1 y x i i i1 y x 2 2 y1 x1 1 If. Therefore the incremental value for either x or y is 1] 5 x = x1 + sign (x) & y = y1 + sign (y) [The sign function makes the algorithm work is all the quadrants] 6 i = 1 (counter) while (i length) { Plot (Integer (x). Integer (y)) x = x + x y = y + y i=i+1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. then x i1 x i y i1 y i x y 2 2 x1 y1 1 DDA Line ALGORITHM Step 1 Read the line end points (x1. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . else length = y x x 2 Length x 1 & y y 2 Length y 1 [This makes either x & y = 1 because length is either absolute value of (x2 – x1) or absolute value of (y2 – y1). y1) & (x2.
Q. 2) (2. 6). y = 6 – 0 = 6 4 x x 2 x1 Length 4 .34) 2. 5) (4.} 7 Stop. x2 = 4.67 = 0. simply open the document you want to convert.67 (1. Use the DDA algorithm to rasterize the line. x = x1 + Sign (x) = 0 + 0. 6) x 0. Step 1. x1 = 0. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .01 2. y2 = 6 2.67 i 1 2 3 4 5 6 Plot (1.69 t 1 2 3 4 5 6 7 6. Length = y = y2 – y1 = 6 5. Compatible across nearly all Windows platforms. 0) to (4.68 3. 3) (3. 1) (1. y 6 y 2 y1 6 1 Length 6 3. Consider the line from (0.02 4. x = 4 – 0 = 4. 4) (3. click “print”. y1 = 0. y = y1 + Sign (y) =0+1 =1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.35 4.
Compatible across nearly all Windows platforms. 1) (2. Consider a line from (0. 3) (4. x1 = 0 y1 = 0 x2 = 6 y2 = 6 2. x = x1 + Sign (x). click “print”. 2) (3. 5) x 1 2 3 4 5 6 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.Q. x =  6 – 0  = 6 y =  6 – 0  = 6 3. 0) to (6. length = x =  x2 – x1  = 6 4 . 6) use the DDA algorithm to rasterize. x x 2 x1 6 1 Length 6 y 2 y1 6 y 1 Length 6 y = y1 + Sign (y) =0+1 =1 y 2 3 4 5 6 5. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . simply open the document you want to convert. 1. =0+1 =1 i 0 1 2 3 4 5 Plot 1 (1. 4) (5.
simply open the document you want to convert. it is an efficient method for scan converting the straight line. it is possible to determine the better pixel to represent the line path. Hence. e = 2 * y . 6) BRESENHAM’S LINE DRAWING ALGORITHM Bresenham’s Algorithm uses only integer addition. it implies the pixel below the line is closer to the true value. Thus by checking the sign of the error term. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . the following actions are taken. This distance is called the Decision Variable or error represented as ‘e’. subtraction and multiplication by 2 which the computer can perform rapidly. click “print”. The algorithm always increments either x or y by one unit depending on the slope of the line. while (e 0) { y=y+1 e = e – 2 * x } x=x+1 e = e + 2 * y pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. it implies that the pixel above the line is closes to the true value. where y = y2 – y1 x = x2 – x1 According to the value of e. The basic principle is to select an optimum raster location to present a straight line.6 (6. The increment in the other variable is determined by examining the distance between the actual line location and the nearest pixel.x. if e 0. If e 0. Compatible across nearly all Windows platforms.
i = 1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. x = x2 – x1 = 13 – 5 = 8 y = y2 – y1 = 9 – 5 = 4 3. 9). DAL to rasterize the line. Ex 1. simply open the document you want to convert. y = 5 4. y1) & (x2. x = 5. y2) such that they are not equal. Compatible across nearly all Windows platforms. 2.x [Initialize value of decesion variables or error] 5. x1 = 5 x2 = 13 y1 = 5 y2 = 9 2. y) 7. Use the B. If (i x) go to step 6 10. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . while (e 0) { y=y+1 e = e2 * x y x=x+1 e = e + 2 * y 8. i = i + 1 9. x = x2 – x1 & / y = y2 – y1 3.ALGORITHM STEP 1. click “print”. 5) to (13. e = 2 * y . e = 2 * y . Read the line end points (x1. Stop.x =2*4–8 =0 5. Initialize starting point as x = x1 & y = y1 4. Initialize counter i = 1 6. 1. L. Plot (x. Consider a line from (5.
2. 5) (6. 5) x 5 3 y 2 6 e 4 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 8) (12. 6) (8. simply open the document you want to convert. x = 2 y=5 4. click “print”. Apply Bresenham’s line drawing algorithm to plot the line. 10). 6) (7. Compatible across nearly all Windows platforms. 9) x 5 6 7 8 9 10 11 12 13 y 0 6 6 7 7 8 8 9 9 e 8 0 8 0 8 0 8 Ex. e = 2 * y . 1. x = x2 – x1 = 10 – 2 = 8 y = y2 – y1 = 10 – 5 = 5 3. 8) (11. 7) (9. i = 1 i 1 Plot 2 (2. x1 = 2 x2 = 10 y1 = 5 y2 = 10 2.x = 2 x 5 – 8 = 2 e=2 5. Consider a line from (2. 7) (10. 5) to (10.i 1 2 3 4 5 6 7 8 Plot 5 (5. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
7) (7. simply open the document you want to convert. 10) 4 5 6 7 8 9 10 6 7 8 8 9 10 10 6 4 2 +8 2 4 CIRCLE GENERATING ALGORITHM A Circle is a symmetric figure. 6) (5.2 3 4 5 6 7 8 (3. Compatible across nearly all Windows platforms. MIDPOINT CIRCLE GENERATING ALGORITHM pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 7) (6.g. 6) (4. 8) (8. If point A is calculated with circle generating algorithm then 7 more points can be drawn by just reflection. click “print”. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . e. 9) (9. Thus a circle generating algorithm can take advantage of circle symmetry to plot 8 points by calculating the coordinate of any one point. It has 8way symmetry.
then the midpoint is outside or on the circle boundary & yi1 is closer to the circle boundary. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .r di+1 = (xi+1) + 1 + 2xi+1 + (yi+1) – yi+1 + ¼ . The incrementry calculation can be determined to obtain the successive decision parameter. So the xcoordinate who is in +ve direction & ycoordinate who is in –ve direction. simply open the document you want to convert. yi – ½) 2 2 2 = (xi + 1) + (yi – ½) – r 1 If di < 0. yi1) is close to the circle. put (xi+1) – r = di – (yi – ½) 2 2 2 2 2 di+1 = di –(yi – ½) + 1 + 2xi+1 + (yi+1) – yi+1 + ¼ 2 2 = di – yi – ¼ + yi + 1 + 2xi+1 + (yi+1) – yi+1 + ¼ 2 2 i = di – [(yi) – (yi+1) ] – [yi+1 – y ] + 1 + 2xi+1 2 2 di+1 = di [(yi+1) – (yi) ] – [yi+1 – yi] + 1 + 2xi+1 where yi+1 is either yi or yi1 1) If di < 0 then yi+1 = yi di+1 = di + 2(xi+1) + 1 2) If di > 0 then yi+I = yi1 2 2 di+1 = di + [(yi1) – (yi) ] – [yi –1 – yi] + 1 + 2xi+1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 2 2 2 Parde (x. So for that purpose the decision parameter is used which uses the circle function.r 2 2 2 From 1. The 2 possible y positions are yi and yi1 and at same position xi and xi+1. yi) as (xi+1. We have to determine whether the pixel at position (xi+1. If di 0. the midpoint is inside the circle and the pixel on the scan line yi is closer to the circle boundary. We take unique steps in x direction and make use of decision parameters to determine which of the 2 possible ypositions are closer to the circular path of each step. If plots 1/8 part of a circle is from 90 to 45.The Midpoint Circle Generating algorithm uses 8way of symmetry of the circle th generated. y) = x + y – r The decision parameter di = Parde (xi + 1. click “print”. Compatible across nearly all Windows platforms. 2 2 2 di+1 = (xi+1 + 1) + (yi+1 – ½) – r 2 2 2 = (xi+1) + 2xi+1 + 1 + (yi+1) – yi+1 + ¼ .
r ALGORITHM Step 1. y0) = (0. Compatible across nearly all Windows platforms. simply open the document you want to convert. Determine the symmetry points Step 6. Do { Plot(x. Stop. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .di+1 = di + 2xi+1 + 1 + [(yi) – 2yi + 1 – (yi) ] – [yi – yi + 1] di+1 = di + 2xi+1 + 1 – 2yi Initial decision parameter at start position (x0. r) d0 = Farde (0. click “print”. 2 2 ELLIPSE GENERATING ALGORITHM Ellipse is an elongated circle with a major axis & a minor axis. y) If (d < 0) { x=x+1 y=y d = d + 2x + 1 } else x=x+1 y=y–1 d = d + 2x – 2y + 1 } } while (x < y) Step 5. Step 2. Read the radius r of the circle. Initialize the starting point x = 0 & y = r Step 3.25 . r – ½) 2 2 2 = (0 + 1) + (r – ½) – r 2 2 =1+r –r+¼r =1+¼r = 5/4 – r d0 = 1. Calculate the initial value of the decision parameter as d0 = 1.25 – r Step 4.
We define an ellipse function as ellipse (x.x2 y2 Eqnofellip seis 1 rx 2 ry 2 ry x + rx y = rx ry 2 2 2 2 2 2 ry x + rx y – rx ry = 0 Midpoint ellipse algorithm 2 2 2 2 2 2 The midpoint ellipse algorithm is applied throughout the first quadrant in two parts. y ) outsideell pseboundar oundary ipsebounda y ry The ellipse slope is calculated as rx ry 2 x 2 rx 2 ry 2 dy d ( y 2 ) ry 2 (x rx 2 dx dx dy ry 2 . We start at position (0. y ) 0 ( x . click “print”. y ) anellipseb 0 ( x . and taking unit step in the y direction where the slope has a magnitude greater than 1. y ) insideelli ( x . We process this quadrant by taking unit steps in x direction where the slope of the curve has a magnitude less than 1. ry 2 2 y . Compatible across nearly all Windows platforms. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . simply open the document you want to convert. 2 y dx dy 2 x . 2 x 0 rx 2 . y) = ry x +rx y – rx ry which has the following properties 2 2 2 2 2 2 fellipse 0 ( x . rx 2 dx 2 x . ry 2 dy 2 2 yrx 2 dx y 2 2 2 ) d dx ( rx 2 ry 2 ) pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. ry) and step clockwise along the elliptical path in the first quadrant shifting from unit steps in x to unit steps in y when the slope becomes less than –1.
Compatible across nearly all Windows platforms. the midposition outside or on the ellipse boundary. yR – ½) 2 2 2 2 2 2 = ry (xR+1) + rx (yK1/2) – rx ry 3 2 2 If P1k < 0.rx 2 We move out of region 1 whenever 2x.ry 2 1 2 y. click “print”. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .Differentiating the eqn Let the boundary between region 1 &2 dy 1 dx 2 x.ry 2yrx Region 1 The decision parameter at midpoint is 1 P k = fellipse (xR + 1. and we select the pixel on the scan line yk1 at the next sampling position pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. the midpoint is inside the ellipse and the pixel of scan line yk is closer to the ellipse boundary.ry 2 2 y.rx 2 Slope x 2 . simply open the document you want to convert. Otherwise.
Compatible across nearly all Windows platforms. ry1/2) 2 2 2 2 2 P 0 = r y + rx (ry – ½) – rx ry 1 2 2 2 P 0 = r y +r xry + rx /4 Region 2 Over region 2.P = fellipse (xk+1 + 1. we sample unit steps in negative y direction and the midpoint is now taken between the horizontal pixels at each step. yk – 1) pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. the value of decesion parameter is obtained by evaluating the ellipse function at the start position (0. In this region the decision parameter is evaluated as 2 P k = fellipse (xR + ½. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . yk+1 – ½) 2 2 2 2 2 2 = ry [(xR+1) + 1] + rx [yR+1 – ½] – rx ry from 1 2 2 2 2 2 2 P k+1 = ry [(xR+1) + 2(xR+1) + 1] + rx [(yR+1) – (yR+1) + ¼] – rx ry P 1 k+1 1 k+1 = ry (xR+1) + 2ry (xR+1) + ry + rx (yR+1) – rx (yR+1) + rx – rx ry = P k – rx (yk – ½) + 2ry (xR+1) + ry + rx (yR+1 – ½) 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 k+1 P From Eqn 3 P 1 k+1 1 = P k + 2ry (xR+1) + ry + rx (yR+1 – ½) – rx (yR – ½) 4 1 2 2 2 2 2 2 If P k < 0. simply open the document you want to convert. yk+1 = yk 1 1 2 2 P k+1 = P k +2ry (xR+1) + ry & If P k 0. click “print”. ry) P 1 0 1 1 = fellipse (0+1. yR + 1 = yk – 1 1 1 2 2 2 2 2 P k+1 = P k + 2ry (xR+1) + ry + rx [(yR – 1 – ½) – (yR – ½) ] 1 1 2 2 2 2 2 P k+1 = P k + 2ry (xR+1) + ry + rx [(yR – 3/2) – (yR – ½) ] 1 1 2 2 2 P k+1 = P k + 2ry (xk+1) + ry + rx (2 – 2yR) 1 1 2 2 2 P k+1 = P k + 2ry (xR+1) + ry – 2rx (yR1) In region 1.
click “print”.P k = ry (xk + ½) + rx (yk – 1) – rx ry 2 2 2 2 2 2 2 2 If P k > 0. simply open the document you want to convert. y0 1 2 P 2 0 1 ry x0 rx 2 ( y0 1) rx 2 ry 2 2 2 POLYLINE pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.e. the midpoint is outside the ellipse boundary and we select the pixel at position 2 xR+1. Compatible across nearly all Windows platforms.P k 1 ry x R 1 rx 2 ( y k 1 1) 2 rx 2 ry 2 2 1 P 2 k 1 ry 2 ( xR 1 ) 2 ( x R 1) rx 2 [( y R 1 ) 2 1 2( y R 1 )] rx 2 ry 2 4 2 2 2 P 2 k 1 P 2 k rx 2 ( y k 1) 2 ry 2 ( xk 1) P 2 k P 2 k 2 1 1 2rx 2rx ( yk 1) rx ry xk 1 y k 2 2 2 2 2 1 P 2 0 fellipse x . If P k < 0 then at the next sampling position 1 i. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
P1. simply open the document you want to convert. 2.A polyline is a chain of connected line segments.e. Types are – convex & concave polygon 1. TYPES OF PLYGON The classification of polygons is based on where the line segment is joining any two points within the polygon is going to lie. CONVEX POLYGON A convex polygon is a polygon in which the line segment joining any 2 points within the polygon lies completely inside the polygon. click “print”. POLYGON When starting point & the terminal point of any polyline is same i. The first vertex is called the initial or starting point & the last vertex is called final or terminal point. P2. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . when polyline is closed then it is called as a polygon. & so on. Compatible across nearly all Windows platforms. CONCAVE POLYGON pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. It is specified by giving the vertices P0.
simply open the document you want to convert. Compatible across nearly all Windows platforms. POLYGON FILLING pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. This method is also known as even off method of determining the points inside the polygon. If there are odd number of intersections then the point is inside the polygon otherwise it is outside the polygon. One simple method to determine whether a point is inside a polygon or not is to determine an inside outside test. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . click “print”. Now count the number of intersections of the line segments with the polygon boundary. Construct the line segment between the point in question and a point known to be outside the polygon. Inside – Outside or Odd Even Test To show that a polygon is a solid object we need to set pixel inside the polygon as well as on the boundary.A Concave Polygon is a polygon in which the line segment joining any 2 points within the polygon lies partially outside the polygon.
For each scan line crossing the polygon. scanning from left to right. 1. this algorithm locate the intersection points of the scan line with the polygon edges. above and below. 2. The scanline algorithm first finds the largest & the smallest of y values of the polygon. simply open the document you want to convert. This approach is called the flood fill because colour flows from the seed pixel until reaching the polygon boundary like water flooding on the surface of a container. Compatible across nearly all Windows platforms. 8 Connected In this case. These intersection points are sorted from left to right. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. SCANLINE ALGORITHM The fig illustrates the scanline algorithm for filling of the polygon. 1. the pixelposition that are to the right. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . along with the 4 pixel positions used in the 4connected method. 4 Connected In this case. click “print”. The current pixel are tested. There are 2 basic approaches to fill the polygon. it then starts with the largest y value and works its way down. left. and the corresponding positions between each intersection pair are set to the specified fill colour. Scan – Line Method FLOOD FILL METHOD In this approach we start from a given seed point known to be inside the polygon and highlight outwards from this point until we encounter the boundary pixels. 4diagonal pixels are also tested. in the manner of a Raster display. Flood – Fill Method 2. There are 2 methods for proceeding to the neighboring pixels.Filling in the polygon means highlighting all the pixels while lie inside the polygon with any colour other than the background colour.
they are sorted from left to right the paired & pixels between the paired points are set to the fill colour. a special handling is required t find the exact intersection points. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . click “print”. According to insideoutside tests. Hence it is considered an even point i. circle. line. Raster Algorithms 2.1 DDA (Digital Differential Analyzer) Algorithm – pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Let us start with the drawing algorithms. the other end points (B & D) of the two line segments of the polygon lie on the same side of the scan line. the other end points D & F. polygon. of the two line segments of the polygon lie on opposite side of the scan line. they are considered as 2 intersecting points. As shown in the figure above each scan line intersects the vertex of the polygon. ellipse etc. when the intersection points are even.1. hence they are considered as a single intersection point as odd point.e. Compatible across nearly all Windows platforms. text.1 Line Drawing Algorithms – In computer graphics. intersection point is a vertex. curve. But in some cases. 2. When scan line intersects polygon vertex. For scan line 1. These graphics primitives are pixel. For scan line 2. simply open the document you want to convert. complex objects are formed using graphics primitives. The important task in this algorithm is to find the intersection points of the scan line with the polygon boundary.
The DDA is an algorithm for calculating the pixel positions along a line. This is done, by taking 7 unit steps with one of the coordinates and calculating corresponding values for other coordinated case1 If absolute value of the slope is less than or equal to 1, then x coordinate is changed in unit steps and corresponding change in y is calculated. The equation of the line is given as, y = mx + h Differentiating the above equation with respect to x we get, dy/dx = m dy = mdx Since, x is changed in unit steps, dx = 1 and dy = m From the above equations, we can write, x1 + 1 = x1 + 1 y1 + 1 = y1+m Case2 If absolute value of slope is greater than 1, then y is changed in unit steps and corresponding change in x is calculated. Differentiating the equation of the line with respect to y we get,
1 m
dx dy
dx = (1/m) dy Since, y is changed in unit steps, dy = 1 and dx = (1/m) 2.1 Prepared by Samir Lele From the equations of dx and dy, we can write, x1+1 = x1 + 1/m y1+1 = y1 + 1 Thus, in both the cases, if we know (x1, y1), then we are in position to determine (x1+1, y1+1). The process is started from the endpoints of the line and is stopped when other endpoint reached. The above process can be written in steps as follows, Algorithm: 1) Read both the end points as (x1, y1) and (x2, y2).
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
2) Calculate chx and chy as, chx x2  x1 chy y2  y1 3) If abs (chx) > abs (chy) Then steps abs (chx) Else steps abs (chy) 4) Calculate xinc and yinc as, xinc chx / steps yinc chy / steps 5) Start with first endpoint and display it, x x1 y y1 putpixel (x, y) 6) Repeat following, steps times. a) Increment x as, x x + xinc b) Increment y as, y y + yinc c) Display the pixel, putpixel (x, y) Disadvantatge – Since, DDA algorithm uses division operations, involves floating point operations and hence requires more time. 2.1.2 Bresenham’s Line Drawing Algorithm – This algorithm use only integer arithmetic and hence it is more efficient. As shown in the diagram, say a point (4, 5) is drawn. Now, we have to decide the next point in the line. It can be (5, 5) or (5, 6). This is because, actual line is passing through such a point, which can not be represented on the screen. Hence, we have to select nearer integer value. Let us consider a line, with positive slope that is less than or equal to 1. Therefore, x is changed in unit steps. Let us assume that, a point (x1, y1) is drawn and we have to decide the next point. We have two options, either (x1 + 1, y1) or (x1 + 1, y1 + 1). One of these two points is selected, whichever is nearer to actual position.
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
From this diagram, we can write following equations, y = m (x1 + 1) + h d1 = y – y1 d1 = m (x1 + 1) + h – y1 d2 = (y1 + 1) – y d2 = y1 + 1 – m (x1 + 1) – h The difference d1 – d2 is calculated as, d1 – d2 = m (x1 + 1) + h – y1 – y1 – 1 + m (x1 + 1) + h d1 – d2 = 2m (x1 + 1) – 2y1 + 2n1 Substitute m as y / x d1 – d2 = (2y / x) (x1 + 1) – 2y1 + 2h1 x (d1 – d2) = 2y (x1 + 1) – 2y1x+ (2h – 1) x Let us call x (d1 – d2) as P1. P1 = 2y (x1 + 1)  2xy1 + (2h – 1) x  1 From the eqn. 1, we can calculate P1 + 1 as follows, P1+1 = 2y (x1+1 + 1)  2xy1+1 + (2h1) x P1+1 = 2y (x1 + 2) – 2xy1+1 + (2h1) x  2 The eqn. 2 – 1 gives, P1+1 = 2y (x1 + 2 – x1 – 1)  2xy1+1 + 2xy1 P1+1 = P1 + 2y  2x (y1+1 – y1) 3 If P1 is negative, then d1 < d2 and hence y1+1 = y1. By substituting this condition, in eqn 3 we get, P1+1 = P1 + 2y 4
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
P1 = 2y (x1 + 1) – 2xy1 + (2y1 – 2mx1 – 1) x P 1 2 y ( x 1 1 ) 2 xy P 1 2 yx 1 1 (2 y1 2 1 2 y 2 xy 2 xy 1 y x1 1) x x 2 yx 1 x P1 2 y x Thus. y1) x x1 yy pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.2x 5 Thus.If P1 is zero or positive then d1 d2 and hence y1+1 = y1 + 1. we can summarize above calculations as. Compatible across nearly all Windows platforms. 2) Calculate x and y as x abs (x2 – x1) y abs (y2 – y1) 3) Initialize the value of (x. Algorithm 1) Read both the end points of a line as (x1. In that case. The equations in this case will be as follows. P1+1 = P1 + 2y . In this case.x) if P1 0 Similar equations can be obtained for the line whose absolute of the slope is greater than 1. if we know P1. y) as (x1.y P1+1 = P1 + 2x if P1 < 0 P1+1 = P1 + 2 (x . y2). y is changed in units steps and the corresponding change in x is calculated. h – y1 – mx1 in the above equation. P1 should be known. from eqn 4 and 5 we can calculate P1+1. P1 = 2y . select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .y) if P1 0 All the six equations do not involve floating point calculations and hence it will be faster than DDA line drawing algorithm. By substituting this condition in eqn 3 we get. y1) and (x2. P1 = 2y (x1 + 1) – 2y1x + (2h1) x P1 = 2y (x1 + 1) – 2y1x + (2h1) x Let us substitute.x P1+1 = P1 + 2y if P1 < 0 P1+1 = P1 + 2(y . P1 = 2x . simply open the document you want to convert. click “print”. The complete process can be written in steps as follows.
Begin P P + 2 (x . simply open the document you want to convert.x) y y + yinc end putpixel (x. y) end end Problem – Apply Bresenham’s line drawing algorithm to the end points.4) Plot the pixel putpixel (x. Compatible across nearly all Windows platforms. P P + 2x Else. 15) pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.y b) While y < > y2 do Begin Y y + yinc If ( P < 0) Then. y) End Else Begin a) Initialize the parameter as P 2x . y1) = (20.y) X x + xinc end putpixel (x. y2) = (12. click “print”. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 20) and (x2. y) 5) Decide the increment value of x and y If (x1 < x2) Then xinc 1 Else xinc 1 If (y1 < y2) The yinc 1 Else yinc 1 6) Decide whether change in x is greater or change in y is greater and change the corresponding coordinate in unit steps and calculate other coordinate accordingly. If (x y) Then Begin a) Initializing the parameter P 2y .x b) While x < > x2 do Begin x x + xinc If P < 0 Then P P + 2y Else Begin P P + 2 (y . (x1.
Let us say that. xinc 1 Since y1 < y2 i. The calculations can be done as shown below. xi 20 19 18 17 xi 16 15 14 13 yi Pi 20 2 19 4 19 6 18 0 yi Pi 17 6 17 4 16 2 16 8 Pi+1 4 6 0 6 Pi+1 4 2 8 2 Plotted pixel xi+1 yi+1 20 19 19 18 19 17 18 16 17 Plotted xi+1 15 14 13 12 pixel yi+1 17 16 16 15 20 2. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 20 < 12 is false. 2.e.e. 20 < 15 is false. The equation of the circle is x + y = r 2 2 2 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. yi) is drawn.Ans – x abs (12 – 20) 8. The next point to be drawn is to be decided. The parametric equations Pi and Pi+1 are calculated in the same manner. the process is similar to the drawing algorithm. a point (xi.1. click “print”. simply open the document you want to convert. yi – 1). Compatible across nearly all Windows platforms. y abs (15 – 20) 5 Since x1 < x2 i. It can be either (xi+1.2 Circle Drawing Algorithms There are two different types of algorithms to draw the circle. yinc 1 Since x < y is true.1 Bresenham’s Circle Drawing Algorithm – In the Bresenham’s circle algorithm. yi) (xi + 1. then part of step 6 of the algorithm will come in picture.
Compatible across nearly all Windows platforms. d1 < d2 and hence yi+1 = yi Pi+1 = Pi + 4xi + 6 . Pi = d1 – d2 Pi = yi – (r – (x1 + 1) ) – (r – (xi + 1) – (yi – 1) ) i 2 2 2 2 2 2 P = yi + r + (xi + 1) – r + (xi +1) + (yi – 1) 2 2 2 2 Pi = 2 (xi + 1) + yi + (yi1) – 2r 1 From the equation we can write. then it means that. 2 2 2 2 d1 = yi – y and d2 = y – (yi – 1) 2 2 2 i2 2 2 d1 = yi (r – x ) = y – (r – (xi + 1) ) 1 x = xi + 1 2 2 2 d1 = yi – (r – (xi+1) ) Similarly.4 If Pi is positive or zero. 2 2 2 2 Pi+1 = 2(xi+1 + 1) + yi+1 + (yi+1 – 1) – 2r 2 2 2 2 Pi+1 = 2 (xi+1 + 1) + yi+1 + (yi+1 – 1) – 2r 2 2 2 2 Pi+1 = 2(xi + 2) + yi+1 + (yi+1 – 1) – 2r 2 2 2 2 2 2 2 The eqn 2 –1 gives.1) 2 2 2 2 2 2 Pi+1 – Pi = 2[xi +4xi+4xi 2xi1] + yi+1 + (yi+1 – 1) – yi – (yi – 1) 2 2 2 2 Pi+1 – Pi = 2(2xi+3) + yi+1 + yi+1 – 2yi+1 + 1 – yi – yi + 2yi – 1 2 2 Pi+1 – Pi = 4xi + 6 + 2yi+1 – 2yi+1 – 2yi + 2yi 2 2 Pi+1 = Pi + 4xi + 6 + 2 (yi+1 – yi ) –2 (yi+1 – yi) . r) assuming (0. d1f d2 and hence Yi+1 = yi –1 2 2 Pi+1 = Pi + 4xi + 6 + 2 [(yi – 1) – yi ] – 2[yi1 – yi] 2 2 Pi+1 = Pi + 4xi + 6 + 2 [yi – 2yi + 1 – yi ] + 2 Pi+1 = Pi + 4xi + 6 + 2 [2yi + 1] + 2 Pi+1 = Pi + 4xi + 6 – 4yi + 2 + 2 Pi+1 = Pi + 4(xi – yi) + 10 . we are in position calculate Pi+1 if we know Pi. click “print”. we can write. simply open the document you want to convert. 0) as center of the circle. 2 2 2 2 2 d2 = y – (yi – 1) d2 = (r – x ) – (yi – 1) 2 2 2 d2 = (r – (xi + 1) ) – (y1 – 1) 2 x = xi + 1 The parameter Pi is given as. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . From the diagram2.y =r –x 2 2 2 The circle drawing is started from a point (0. Let substitute I = 1 in equation 1 and hence.3 If Pi is negative. 2 2 2 2 2 2 2 2 Pi+1 – Pi = 2 (xi+2) + y i+1 + (yi+1 – 1) – 2r – 2 (xi+1) – yi – (yi – 1) + 2r 2 2 2 2 2 2 Pi+1 – Pi = 2[(xi+2) – (xi+1) ] + yi+1 + (yi+1 – 1) – yi – (yi . P1 = 2(x1 + 1) + y1 + (y1 – 1) – 2r 2 2 2 2 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.5 From equations 4 and 5 we can say that. However. we must know Pi. then it means that.
Pi+1 = fcircle (xi+1 + 1. yi+1 – ½) 2 2 2 Pi+1 = (xi+1 + 1) + (yi+1 – ½) – r 2 2 2 Pi+1 = (xi + 2) + (yi+1 – ½) – r . yi1). r) P1 = 2(0 + 1) + r + (r – 1) – 2r 2 2 2 P1 = 2 + r + r – 2r+1 – 2r 2 2 P1 = 2 + 2r – 2r + 1 –2r P1 = 3 – 2r . yc). Yi+1 = yi. x x + 1 Let us assume that (xi. then (xi+1. 6 & 7) 5) Call display routine 6) If P < 0 Then P P + 4x + 6 Else Begin P P + 4 (x – y) + 1 yy–1 7) Increment x in unit steps as. 2) Select first point for display. (x1. If the midpoint is outside the circle. r) 3) Calculate the first parameter as. we get Pi+1 = Pi + 2xi + 3 . Pi+1 – Pi = (xi+2) + (yi+1 – ½) – r – (xi+1) – (yi – ½) + r 2 2 2 2 Pi+1 – Pi = (xi + 4xi + 4) + (yi+1 – ½) – (xi + 2xi + 1) – (yi – ½) 2 2 Pi+1 – Pi = 2xi + 3 + (yi+1 – ½) – (yi – ½) 2 2 Pi+1 = Pi + 2xi + 3 + (yi+1 – ½) – (yi – ½) . click “print”. The decision parameter Pi is calculated as follows. then the midpoint lies inside the circle. yi) is drawn.3 If Pi is negative. Compatible across nearly all Windows platforms. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . y1) = (0. y1) = (0. The next point to be drawn is to be determined. If the midpoint is inside the circle. simply open the document you want to convert. then (xi+1.1 The successive decision parameter Pi+1 is obtained as follows.6 The above process can be summarized in steps as follows Algorithm – 1) Read the radius r and center coordinates as (xc. P 3 – 2r 4) While (x < = y) do following steps (step 5. yi1) is closer to the circle path. yi) or (xi+1. yi – ½) 2 2 2 Pi = (xi + 1) + (yi – ½) – r . yi) is closer to circle path. It will be either (xi+1.The first point to be drawn is (x1.4 2 2 2 2 2 2 2 2 2 2 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Pi = fcircle (xi + 1. By substituting this condition in eqn 3.2 The equation 2 – 1 gives.
yc–y) iv) putpizel (xc–x. yi+1 = yi – 1. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . yc) 2) Select first point for display as (x1. then midpoint lies outside the circle or on the circle. Let us substitute i = 1 in eqn 1 and hence. yc+x) vii) putpixel (xcy. we are in position to calculate Pi+1. yc+x) vii) putpixel (xcy.r P1 = 5/4 – r . P1 = (x1 + 1) + (y1 – ½) – r 2 2 P1 = (0 + 1)2 + (r – ½) – r (x1. yc+y) v) putpixel (xc+y. ycx) 2 2 2 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. simply open the document you want to convert.If Pi is positive or zero. yc+y) iii) putpixel (xc–x. 2 2 Pi+1 = Pi + 2xi + 3 + (yi – 3/2) – (yi – ½) 2 2 Pi+1 = Pi + 2xi + 3 + yi – 3yi + 9/4 – yi + yi – ¼ Pi+1 = Pi + 2xi + 3 – 2yi + 2 Pi+1 = Pi + 2 (xi – yi) + 5 . ycx) ii) putpixel (xc+x. yc–y) vi) putpixel (xc+y. Algorithm – 1) Read the radius as r and center coordinates as (xc.5 From equations 4 and 5 we can say that. yc+y) v) putpixel (xc+y. yc+x) ii) putpixel (xc+x. By substituting this condition in equation 3 we get. y1) = (0. ycx) Display Routine i) putpixel (xc+x. click “print”. we must know Pi. r). However. yc–y) iv) putpizel (xc–x. y1) = (0. r) 2 2 P1 = 1 + r – r + ¼ . yc+y) iii) putpixel (xc–x. Compatible across nearly all Windows platforms. 6 & 7) 5) Call display routine 6) If P < 0 Then P P + 2x + 3 Else Begin P P + 2(x – y) + 2 yy–1 end 7) Increment x in unit steps as x x +1 Display Routine – i) putpixel (xc+x. if we know Pi. ycx) viii) putpixel (xcy.6 The above process can be summarized in steps as. 3) Calculate the first parameter as P P 5/4 – r 1–r 4) While (x < = y) do following steps (step 5. yc–y) vi) putpixel (xc+y. ycx) viii) putpixel (xcy.
the magnitude of the slope is greater than 1 and hence y is changed in unit steps and x is calculated accordingly. 70 0 20 37 31 1 20 51. Compatible across nearly all Windows platforms. In midpoint circle algorithm. 70 3 20 7 11 4 20 54. the magnitude of the slope is less than 1 & hence the x is incremented in unit steps & y is calculated. 2 2 2 Fcircle (x. a circle function is calculated as. the x is incremented in unit steps and the corresponding value of y th is calculated. st pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 69 6 19 17 13 7 19 57. 69 5 19 43 17 6 19 56. 69 7 19 13 25 8 18 58. simply open the document you want to convert. 70 4 20 11 43 5 19 55. 50). Y = 20 xi yi Pi Pi+1 xi+1 yi+1 Plotted pixel 0 20 50.Problem – Using Bresenham’s Circle Algorithm. The remaining 7/8 of the circle is achieved using symmetry. 68 Midpoint Circle Algorithm – In this algorithm also. we can obtain following points. centered at (50. the points are calculated only for 1/8 of circle. In region 2. ry) in region 1. y) = 0 if (x. y) lies inside the circle fcircle (x. The process can be started from (0. 70 2 20 21 7 3 20 53. The function of the ellipse can be calculated from the equation of the ellipse. y) lies outside the circle [DIAGRAM] Ellipse Drawing Algorithm (Midpoint) The midpoint ellipse drawing algorithm is applied throughout the 1 quadrant according to the slope of the tagent. In region 1. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . y) lies on circle boundary > 0 if (x. produce the sequence of at least five points along the circumference of the circle with the radius 20. y) = x + y – r From the above equation. click “print”. This process is same as that of in Bresenham’s algorithm. 70 1 20 31 21 2 20 52. In this algorithm also. < 0 if (x.
y) is on the ellipse. y) = 0 if (x. y ) r y x 2 r x y 2 r x r y The function will have following properties. In the first region. The slope of the tangent to the ellipse at (x. 2 2 2 2 2 2 ry x + rx y –rx ry = 0 Differentiating the above equation with respect to x. simply open the document you want to convert. the slope becomes –1. click “print”. The slope of the ellipse is to be calculated after defining every point. Compatible across nearly all Windows platforms.1 The successive decision parameter P1i+1 can be calculated as. ry dy 2 2 y . > 0 if (x. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . < 0 if (x. y) is outside the ellipse. The new point to be drawn is decided on the sign of the above function. fellipse (x. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.x2 y2 1 rx 2 ry 2 r y x 2 rx y 2 rx r y r y x 2 rx 2 2 y 2 2 2 2 2 2 2 rx r y 2 0 2 2 2 f ellipse ( x . yi – ½) 2 2 2 2 2 2 P1i = ry (xi + 1) + rx (yi – ½) – rx ry .r 2 2 x 0 2 y 2 yr dy dx xr yr 2 y x 2 AT the junction of two regions. This is done to check whether the region 1 is finished or not. y) can be calculated as shown follows. The decision parameter is calculated as P1i = fellipse (xi + 1. xi+1 = xi + 1.r x / dx dy dx 2 x . we get 2 x . y) is inside the ellipse.
select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . ry) 2 2 2 2 2 2 P1i = ry (xi+1) + rx (yi – ½) – rx ry P1i = ry (0+1) + rx (ry1/2) – rx ry 2 2 2 2 2 = ry + rx (ry – ry + ½) – rx ry 2 2 2 2 2 2 2 P1i = ry + rx ry – rx ry + ¼ rx – rx ry 2 2 2 P1i = ry – rx ry + ¼ rx . we get. then midpoint lies inside the circle.3 If P1i is negative then yi+1 = yi.7 P2i+1 = ry (xi+1 + ½) + rx (yi+1 – 1) – rx ry 2 2 2 2 2 2 P2i+1 = ry (xi+1 + ½) + rx (yi – 2) – rx ry 2 2 2 2 2 2 2 2 2 2 2 2 . yi – 1) 2 2 2 2 P2i = ry (xi + ½) + rx (yi – 1)2 – rx ry . The next point can be either (xi. yi – 1). The decision parameter is calculated as. By substituting this condition in equation 3.1/2) ] 2 2 2 2 P1i+1 – P1i = ry (2xi + 3) + rx [(yi+1 – ½) – (yi – ½) ] 2 2 2 2 P1i+1 = P1i + ry (2xi + 3) + rx [(yi+1 – ½) – (yi – ½) ] . P2i = fellipse (xi + ½.9 If P2i is negative. Compatible across nearly all Windows platforms. When absolute of slope becomes 1. Let us calculate. The point (xi.2 The equation 2 – 1 can be given as.4 If Pi is positive or zero. y1) = (0. 2 2 2 2 2 2 P2i+1 – P2i = ry [(xi+1 + ½) – (xi + ½) ] + rx [(yi – 2) – (yi – 1) ] 2 2 2 2 2 2 P2i+1 – P2i = ry [(xi+1 + ½) – (xi + ½) ] + rx [yi – 4yi + 4 – yi + 2yi 2 2 2 2 P2i+1 = P2i + ry [(xi+1 + ½) – (xi + ½) ] + rx (2yi + 3) . 2 P1i+1 = P1i + ry (2xi + 3) . 2 2 2 2 2 2 2 2 2 2 P1i+1 – P1i = ry (xi+2) + rx (yi+11/2) – rx2ry – ry (xi+1) – rx2 (yi1/2) + rx ry 2 2 2 2 2 2 P1i+1 – P1i = ry [ xi + 4xi + 4 – xi – 2xi – 1] + rx [(yi+1 – ½) – (yI . simply open the document you want to convert. the region 1 is finished and the region 2 gets started. then yi+1 = yi – 1 2 2 2 2 P1i+1 = P1i + ry (2xi+3) + rx [(yi – 3/2) – (yi – ½) ] 2 2 2 2 P1i+1 = P1i + ry (2xi+3) + rx [yi – 3yi + 9/4 – yi + yi – ¼] 2 2 P1i+1 = P1i + ry (2xi+3) + rx (2yi + 2) . In region 2. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.8 The equation 8 – 7 gives.1) or (xi + 1. yI .6 With the above process. parametric equations in region 2. yi) is drawn.P1i+1 = ry (xi+1 + 1) + rx (yi+1 – ½) – rx ry 2 2 2 2 P1i+1 = ry2 (xi+2) + rx2 (yi+1 – ½) – rx ry 2 2 2 2 2 2 . we can complete region1. click “print”.5 Let us calculate P1i using (x1. the y coordinate is decremented in unit steps.
select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 13.xi+1 = xi + 1 2 2 2 2 P2i+1 = P2i + ry [(xi + 3/2) – (xi + ½) ] + rx (2yi + 3) 2 2 2 2 P2i+1 = P2i + ry [xi + 3xi + 9/4 – xi – xi – ¼] + rx (2yi + 3) 2 2 P2i+1 = P2i + ry (2xi + 2) + rx (2yi + 3) . 7. Compatible across nearly all Windows platforms. 14 while (y > = 0) 12) Call display routine 13) If P2 < 0 Then Begin 2 2 P2 P2 + ry (2x+2) + rx (32y) x x+1 end 2 Else P2 P2 + rx (32y) Boundary – Fill Algorithm – pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.11 The P2i will be calculated from the last point of region1.(ry x / rx y) 5) Repeat steps 6.10 If P2i is positive or zero. 2 P2i+1 = P2i + rx (2yi + 3) . 9 while (abs (slope) < 1) 6) Call display routine 2 7) If P1 < 0 Then P1 P1 + ry (2x + 3) Else Begin 2 2 P1 P1 + ry (2x + 3) + rx (2y + 2) yy–1 end 8) Increment x in unit steps as x x + 1 2 2 9) Update the slope as – (ry x / rx y) 10) Calculate the decision parameter for region 2 2 2 2 2 2 2 P2 ry (x + ½) + rx (y – 1) – rx ry 11) Repeat steps 12. 1) Read the coordinates (xc. 2 2 2 Pi ry – rx ry + (1/4) rx 3) Select the first point for display as (0.12 Algorithm – The overall process can be summarized in steps as follows. xi+1 = xi By putting this condition in eqn 9 we get. 8. 2) Calculate the initial value of parameter in region 1. then midpoint is outside the ellipse or on the ellipse. yc) and also read rx and ry. simply open the document you want to convert. 2 2 2 2 2 2 P2i = ry (x2 + ½) + rx (y2 – 1) – rx ry . x = 0. ry) i. click “print”. y = ry 4) Calculate slope as 2 2 .e.
boundaryfill (x. four diagonal pixels are also tested. This approach is called as floodfill algorithm. This method is called as Boundary – fill algorithm. as input parameters. y) accepts the fill color and boundary color. click “print”. y. int y. y+1. by starting at a point inside the figure and painting the interior in a specified color or intensity. y. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . if ( (pc ! = bc)& & (pc ! = fc) ) { putpixel (x. that the point is of some different color and hence it is not required to be recolored. void floodfill (int x. an area is not defined with a single color boundary. bc). y). fc. below. bc). fc). boundaryfill (x1. The floodfill algorithm when reaches towards any boundary of any other color. the boundary color is not unique. Floodfill algorithm Sometimes. fc. boundaryfill (x. In the given diagram. fc. If the neighbouring point is not having boundary color as well as not having the fill color. the area is surrounded by areas of different colors. The recursive procedure is written as shown below. int y. then that point is painted with a fill color. These points are above. [DIAGRAM] 4connected areas 8connected areas The algorithm can be written in recursive manner. A boundaryfill algorithm accepts the interior coordinate point (x. int bc) { int pc. y) and uses either 4connected or 8connected areas method. fc. four neighbouring points are tested. then these points are recolored with flood color. The boundaryfill algorithm can also be implemented using 8connected areas. pc = getcolor (x. bc). simply open the document you want to convert. bc). int fc.An area can be filled. y1. Compatible across nearly all Windows platforms. int oc) { pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. In this case. Areas filled by this method are called as 4connected areas. If the neighbouring points are of old color. Such areas are filled by replacing the old color by new color instead of checking boundary colors. Starting from the given interior point. void boundaryfill (int x. The painting proceeds until the figure’s boundary is encountered. then algorithm finds. y. int fc. right and left to the starting point. The algorithm starts from a given interior point 9x. boundaryfill (x+1. alongwith four neighbouring pixels. Thus. The algorithm can be written recursively as follows.
Bit map fonts are simplest to define and display. floodfill (x+1. The text in serif font can be like ABCDEF.if (oc = = getcolor (x. Algerian. y) ) { putpixel (x. y. Courier. The serif type has small lines called as accents at the ends of main character strokes. fc. y1. } } Both the algorithms are recursive and these algorithms works only for small areas. These characters can be displayed with different styles as. y. A simple method to represent character fonts is to use rectangular grid patterns. The character grid is to be mapped to a frame buffer position. In this case. size. Another method to describe the character shapes in particular font. Two different representations are used for storing fonts. oc). numbers. Text Generation – Letters. the interior of the character outline is to be filled using some algorithm. The text in sansserif font can be like ABCDEF. y. The overall design style for a set of characters is called as typeface. click “print”. There are no. fc. The sets of character shapes are referred as bitmap fonts. fc. underline. boldface. The typefaces can be divided into two broad groups as serif and sansserif. floodfill (x. The sansserif font does not have accents. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . New York. Every graphics package pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. italics. of fonts which are developed for displaying characters. oc). floodfill (x1. These algorithms can also be made nonrecursive. The typeface and font are used interchangeably. is using straight lines or curve sections. set of characters is called as outline font. fc. Arial etc. the bit map fonts can be used to display the characters in different styles and sizes. floodfill (x. digits and other special symbols can be displayed in variety of sizes and styles. Compatible across nearly all Windows platforms. Wild Latin. Text Attributes – The appearance of the characters can be changed by changing the attributes of the characters. fc). but then the logic is slightly complicated than recursive algorithms. such as Times New Roman. Attributes can be set for a single character or group of characters. oc). oc). To display characters in outline form. y+1. color and orientation. The attributes can be defined as font. simply open the document you want to convert.
For any given set of control points. Using these points.Bk . These points are represented as Pk (xk. k 0 Bk . click “print”. Bk . n ( u ) c ( n . The curve is formed by accepting n+1 control points. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . CG. The characters can also be displayed in different sizes as.CG.u k (1 u ) n k andc n . an approximate curve is formed by adding sequence of polynomial functions. k The equation 1 can be written as. n p (u ) Pk .7 Bezier Curves  This method of constructing curves was developed by the French Engineer Bezier.CG 2. zk) for k varying from a to n. which are formed from the coordinates of the control points.Bk . CG. n! k ! ( n k )! n x(u) xk . Compatible across nearly all Windows platforms.CG.provides these types of facilities. n (u ) k 0 n z (u ) zk . simply open the document you want to convert.Bk . yk. n (u ) where. the Bezier function p(u) is calculated as. k ). CG. n (u ) k 0 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. n (u) k 0 n y(u ) yk .
select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . k will be varying from 0 to 3. B2. The blending functions will be polynomials of degree n.n (u) are called as Blending functions. Compatible across nearly all Windows platforms. Thus. The following diagrams represents different curves alongwith convex hull represented with dotted lines. The Bezier curve always lies inside the CONVEX HULL represented by central points. This is because.3(u) and B3. if n+1 control points are given. If the curve is defined by 4 points. it means that n+1 = 4. In this case. there will be 4 Blending functions as.The polynomials Bk.3(u). All these functions can be calculated using Bk. B1. B0.3(u). click “print”. simply open the document you want to convert.n(u). If the curves are restricted on xy plane for z = 0 then z(u) = 0. Hence n = 3.3(u). these functions blend (mix) the control points to form composite function. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.
B k . Nk.n (u ) k 0 it means that. yk. simply open the document you want to convert. used to produce the smooth curve. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . n+1 control points are given. These points are denoted as Pk n P (u ) Pk . The u varies from 0 to n – t + 2. The positions uj are defined as breakpoints. n + 1 = 5 n=4 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. the Bspline curve can then be defined as.n Since . Using the recursive blending functions and by putting proper values of uj. P (u ) Pk . over various subintervals of range of u. through set of given points. Compatible across nearly all Windows platforms. the Blending functions Nk. In Bspline curve. The blending functions are recursively defined as. click “print”.8 BSpline Curves – The spline is a flexible strip. Nk. different blending functions are dominent than other blending functions. zk).t 1 (u ) ukt u N u k t u k 1 k 1. while defining the curve.t(u) are evaluated with respect to u. N k . t ( u ) k 0 (xk. This feature provides facility of localized control over the curve. u j 0 ifj t j t 1 ift j n n t 2 ifj n The j varies from 0 to n + t. Let us take 5 control points.t = 1 if uk u < uk+1 =0 otherwise N k .t (u ) u uk N u k t 1 u k k .t(u) can be defined as polynomials of degree t1. This range depends on n and t.t 1 (u ) Any term divided by 0 in above calculation is assumed as zero. The breakpoints are defined as follows. all the blending functions are used and hence all of them have some effect to determine each point on the curve. where k varies from 0 to n. A polynomial form of the blending function can be defined recursively. Where. 2. For different ranges of u.
2. The typical blending functions are defined as follows. Similarly. Compatible across nearly all Windows platforms.g. the control points if it passes through them. 1) Control Points – The shape of the curve is controlled by the location of control points. It means that f(x) can have two or more values for the same value of x. u0 = 0. u2 = 0 u3 = 1. at value x. u1 = 0.e.Let us take t = 3. we can see that. 2) Multiple Values – In general. Similarly. x 111 &x .9 Properties of Curves (Bezier as well as Bspline) Following are the general properties of the curves. 0 to 4 – 3 + 2 i. u4 = 2 u5 = 3. the curve should rotate by 90. then they are called as knots. 3) Axis Independence – The shape of an object must not change when control points are measured in a different coordinate system. if the control points are rotated (means coordinate axis is) by 90. u varies from 0 to n – t + 2 i. click “print”. the blending functions are plotted with respect to u. 0 to 7. u7 = 3 Using these breakpoints. which is formed by joining control points. simply open the document you want to convert. The curve often remains within the CONVEX HULL. j varies from 0 to 4 + 3 i. u6 = 3. there 1 11 are three different values of x on the curve as x . 0 to 3. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. A curve is said to interpolate. For e. but the shape will not change. From the diagram. there are two different values of 1 11 y on the curve as y and y . If the curve passes through the control points. f(y) can have two or more values for the same value of y. at value y.e.e. a curve is not a graph of a single valued function of a coordinate. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
then it may change the shape throughout. Ore to control points more the accuracy. these functions have variationdiminishing property. More flexible techniques allow the designer to control the versatility of a curve. While creating joints. For e.g.4) Global or Local Control – When the designer manipulates (modifies) a particular control point. whereas some mathematical functions are such that curve goes smoothly. or a curve may change shape only in the region near the control point. Compatible across nearly all Windows platforms. f (uk+1) – f(uk) decreases as k increases. It means that. then just by placing the third control point. that curve oscillates heavily. a complex shape is not modelled by a single curve. The first behaviour is called as global control and the second behaviour is called as local control. but by several curves pieced together. The global control may be annoying for designer if he is trying for fine adjustment. if two points are given and if we get a line. Order of continuity – Usually. click “print”. This is because. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. designer will have options to control the order of continuity. simply open the document you want to convert. number of additional shapes can be achieved. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . by adding or removing control points. 5) Variationdiminishing property – Some mathematical functions used to determine the curve are such. Such joints are to achieve sharp corners. 6) Versatility – A curve representation that allows limited variety of shapes can frustrate designer. heavyascillations variasiondiminishing curve.
2.3 2. inverse transformation. Rotation about an arbitrary point.1 1. simply open the document you want to convert. homogeneous rotation & translation. Compatible across nearly all Windows platforms. 4.2 2.3 Two Dimensional Transformation Translation Rotation Scaling Homogeneous Coordinates For Translation Rotation Scaling 3.5 * 20 GEOMETRIC TRANSFORMATION * GEOMETRIC TRANSFORMATION Matrices.1 2.1 TRANSLATION pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Rotation about on arbitrary point. 1. scaling transformations. 1. 5. Inverse Transformations. (sine & cos rotation). Reflection & shear. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 1. click “print”.2 1.
simply open the document you want to convert.e . B (7. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . y ) as shown in the figure above. We can translate a two dimensional point by adding translation distances tx and ty to 1 1 the original coordinate position (x. 2) by 3 units in x direction and 4 units is y direction. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. y) to move the point to a new position (x . click “print”. Translate a polygon with coordinates A (2. P Translation is a process of changing the position of an object in a straight line path from one coordinate location to another. x y P 1 x y 1 1 T t t x y The 2 dimensional translation equations is the matrix form: 1 P +P+T x1 x t x i . 10) and C (10. 1 y y t y Ex. 1 x = x + tx 1 1 y = y + ty 2 The translation distance pair (tx. ty) is called a translation vector or shift vector. Compatible across nearly all Windows platforms. 5). Equations 1 & 2 can be expressed in the form of following translation vector.
simply open the document you want to convert. To generate a rotation.2 ROTATION A two dimensional rotation is applied to an object by repositioning it along a circular path in the xy plane. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 2 3 5 A1 A T 5 4 9 7 3 10 B1 B T 10 4 14 10 3 13 C1 C T 2 4 6 1. below. click “print”. Compatible across nearly all Windows platforms. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. we specify rotation angle 0 and the position of the rotation about which the object is to be rotated. Let us consider the rotation of an object about the origin as shown in the fig.
original angular position of point from horizontal. r constant distance of point from the origin. simply open the document you want to convert. Using trignometary. we get. Compatible across nearly all Windows platforms.R sin cos ] sin cos P Where R Rotation Matrix and it is given as R cos sin sin cos Note. For negative values of 0. click “print”. 1 x = x cos . pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .y sin 1 y = y sin + y cos 3 The above equations can be represented in the matrix form 1 [ x y 1 1 ] [ xy P . 1 x = r cos( + ) = r cos cos . Here.r sin sin 1 y = r sin ( + ) = r cos sin + r sin cos 1 The original coordinates are x = r cos y = r sin 2 Substituting 2 in 1. Rotation Angle.
cos sin cos 45 sin 45 R sin cos sin 45 cos 45 1 / 2 1 / 2 1 / 21 / 2 1 / 2 1 2 P [ 43 ] 1 / 21 2 1 [4 / [1 / 2 3/ 27 / 2 24/ 2 3 2] 1. 3) is rotated conter clockwise by an angle of 45. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . Find the rotation matrix and the resultant point. Sol. cos( ) sin( ) R sin( ) cos( ) cos sin R sin cos Ex. click “print”. Compatible across nearly all Windows platforms.3 SCALING A scaling transformation changes the size of an object. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. y1) 1 x = x. y) of each vertex by scaling factors Sx and Sy to produce the transformed coordinates (x1. A point (4. simply open the document you want to convert.Sx 1 & y = y. Sy 1 Scaling factor Sx scales object in x direction and scaling factor Sy scales object in y direction. This operation can be carried out for polygons by multiplying the coordinate values (x.
S y ] P .S x y . Soln. Here Sx = 2 & Sy = 2 Transformation matrix is given as S Theobjectm B C [ 710 [ 102 A B C 1 1 1 20 02 ] ] [ [ [ x 1 atrixisA [ 25 ] x x 1 1 y y 1 1 1 ] ] [ 25 [ 710 [ 102 20 ] 02 ] 20 02 20 02 [ 410 [ 1420 [ 204 ] ] ] 1 2 1 2 3 y 3 ] ] pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.S Values assigned to Sx & Sy that are less than 1. 5). click “print”. reduce the size of the object and values greater than 1 enlarge the size of the object. Compatible across nearly all Windows platforms. Ex. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .The equation 1 can be written in matrix form as S x 0 [ x 1 y 1 ] [ xy ] 0 S y [ x . B (7. Scale a polygon with coordinates A (2. 10). C (10. simply open the document you want to convert. 2) by 2 units in x direction & 2 units in y direction.
select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . Compatible across nearly all Windows platforms. simply open the document you want to convert. click “print”.pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.
HOOGENEOUS COORDINATES In design and picture formation process. points are specified by 3 numbers instead of 2. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . click “print”. But this sequential approach is not efficient. rotations and scaling to fit the picture components into their proper positions. M1 + M2 1 ForTransla i . simply open the document you want to convert. we must calculate the transformed coordinates are translated.e . W) where pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. then they are scaled and finally rotated.2. We have to represent matrix M1 as 3 x 3 matrix instead of 2 x 2 introducing an additional demmy coordinate w. Here. This eliminates the calculation of intermediate values. The homogeneous coordinate is represented as a triplet. many times we may require to perform translation. Each of the basic transformation can be expressed in the general matrix form as 1 P = P . To achieve this we have to eliminate the matrix addition associated with the translation terms in M2 of eqn 1. M M 2 1 tionP IdentityMa Translatio 1 10 P 01 trix tx ty nMatrix cos sin 0 P 0 sin cos Matrix ForRotatio M M 1 2 nP 1 Rotational 0 ForScaling i . This coordinate system is called Homogeneous coordinate system and it allows us to express all transformation equations as matrix multiplication. Compatible across nearly all Windows platforms. Yw. M M 2 1 S x 0 0 P 0 0 S y rix ScalingMat P 1 0 To produce a sequence of transformations with the above equations. A more efficient approach is to combine sequence of transformations into one transformation so that the final coordinate positions are obtained directly from the initial coordinates. (Xw.e .
Compatible across nearly all Windows platforms.1 HOMOGENEOUS COORDINATES FOR TRANSLATION The homogeneous coordinates for translation are 100 T 010 txt y1 wehave [ x txy 100 [ x y 1 ] [ xy 1 ] 010 txt y1 1 1 ty 1 ] 2. y. simply open the document you want to convert. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 2.3 HOMOGENEOUS COORDINATES FOR SCALING Homogeneous Coordinates for scaling are pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.2 HOMOGENEOUS COORDINATES FOR ROTATION Homogeneous Coordinates for cos sin 0 sin cos 0 RotationR 001 cos sin 0 1 1 [ x y 1 ] [ xy 1 ] sin cos 0 001 1 1 [ x y 1 ] x cos y sin x sin y cos 1 ] 2.x Xw W & y Yw W Each 2 dimensional position can be represented with homogeneous coordinate as (x. click “print”. 1) Summary Homogeneous coordinates allow combined transformation. eliminating the calculation of intermediate coordinate values and thus save required time for transformation and memory required to store the intermediate coordinate values.
x1 10 t x x 1 i . pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 2). 3. Consider the centre position (2. S x y Note In the above texts 2.S S x x 1 x 00 y 0 001 y 1 S 0 S x 00 y [ [ 1 y ] . click “print”.3 the object matrix is written first and is then multiplied by required transformation matrix. 2. Perform the following transformations. & D(1. C (3. 1.1 to 2. 1). Thus overall transformation matrices is formed by multiplication of 3 matrices. 3). select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . Translate the square back to the original position. Scale the square with respect to the origin. e . B (3. Consider a square ABCD with coordinate position A (1. 3). y 01 t y y 1 001 1 Ex 1. 1). Reduce it to ½ its size with centre still at (2. Compatible across nearly all Windows platforms. If we wish to write the transformation matrix first and then the of object matrix we have to take the transpose of both the matrices and post multiply the object matrix. S [ 1 xy ] 1 ] 0 001 S 0 . 2) The transformation is carried out in the following sequence. Translate the square such that its centre coincides with origin. simply open the document you want to convert.
500 ] 00 . 500 00 .[ T . 50 T 001 0 . 5 ) C ( 2 .[ T [ 2 .T . 500 ] 00 . 00 . click “print”. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 50 111 0 . 5 . 50 111 0 . S . S . 2 .5 ) D 1 ( 2 .T D 100 010 2 . S . 50 111 1 100 010 2 100 010 221 0 . 500 . 010 221 A A B B C C D A .5 ) (1 . S . Compatible across nearly all Windows platforms.1 .2 .[ T [ 1 . 50 111 1 1 1 . 52 1 S .5 . 5 .T . 51 1 . 50 111 0 . simply open the document you want to convert. 500 00 . 50 21 001 100 010 2 221 100 . 50 1 11 0 . 500 ] 00 .T 2 21 S T 1 0 .T . 51 .2 .T 2 ] [ 131 [ 1 . 51 ] 2 ] [ 111 0 . 51 C . 51 B . 51 ] ] 2 ] [ 311 1 1 1 2 ] [ 331 1 1 D . 5 ) pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.5 .[ T [ 2 . 500 00 . 500 ] 00 . 52 A B 1 1 ] 1 ( 1 .
Soln. click “print”. Give a 3 x 3 homogeneous coordinate transformation matrix for each of the following translations.2. a) Shift the image to the right 3 unit b) Shift the image up 2 unit c) Move the image down ½ unit and right 1 unit. d) Move the image down 2/3 unit and left 4 units. Homogeneous Coordinates for translation are pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . simply open the document you want to convert. Compatible across nearly all Windows platforms.
T a ) T Heretx
100 010 txty 100 010 301
1
3
,
ty
0
b
) T
Heretx 100 010 021
0
,
ty
2
c T
)
Herety 100 010 10 Heretx 100 010
0
. 5
,
tx
1
. 51
d T
)
4
,
ty
0
. 66
40
. 661
3. Find the transformation of a triangle A(1,0), B(0,1), C(1,1) by a) Rotating 45 about the origin and translating one unit in x & y direction. b) Translating one unit in x and y direction and then rotating 45 about the origin. Soln.
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
The Rotation matrix is
cos sin 001 45 45 sin cos 450 450 0 2 0 &
R
R
1 / 1 001
2 1 /
/ 2 1 /
2
Translatio T 100 010 111 R .T
nmatrixis
a
)
1 / 1 001 / 2 / 0 2
2 1 /
/ 2 1 /
2
0 2
100 0 010 111
1 / 1 111 A
1
2 1 /
2 1
0 2 / 0 2 0
A .[ 1 / ] 1 111 1 2 1 1 2
R
.T 2 1 /
] / 2 1
[ 101
1 2 2 1 ) 1 ,
A
1
11 1
2 1 , B
1
1 2
1 ,
1 2
C
1
1
(1 ,
b ) T
. R
100 010 111 2 1 / 2 1 / 2
1 / . 1 001 0 2 0 2 /
2 1 /
/ 2 1 /
2
0 2 0
1 / 1 0 A
1
/ 2 1
A .[ T 1 / ] 1 0
. R 2 1 / 2 1
] / 2 1 0 2 0 )
[ 101
[1 A
/
1
2 (1
3 /
/ 2
2 1 ] , 3 / 2
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
B
1
B .[ T . R ]
1 / 21 / 2 0 [ 011 ] 1 / 21 / 2 0 0 21 [ 1 / B
C
1
2 3 /
2 1] 2 ,3 / 2 )
1
( 1 /
C .[ T . R .] 1 / 2 1 / 2 0 ] 1 / 2 1 / 2 0 0 2 1 / 2 1] 2 ) (0 ,2
[ 111
[ 02 C
1
3. Rotation about an arbitrary point To rotate an object about an arbitrary point we have to carry out 3 steps. 1. Translate point (xp, yp) to origin 2. Rotate it about the origin. 3. Finally, translate the centre of rotation back where it belongs.
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
The translation matrix to move point (xp. The rotation matrix for counter clockwise rotation of point below the origin is cos sin 0 R sin cos 0 001 3.1. Compatible across nearly all Windows platforms. simply open the document you want to convert. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . The translation matrix to move the centre point back to its original position is given as pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. yp) to the origin is 100 T 1 010 xp yp 1 2. click “print”.
Perform a counterclockwise 45 rotation of triangle A(2. yp) is given as 100 cos sin 0 100 sin cos 0 010 T1. 1.100 T 2 010 xpyp 1 Therefore. click “print”.1) pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. B(5.5). simply open the document you want to convert.3) about point (1. C(4. Compatible across nearly all Windows platforms.R. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . the overall transformation matrix for a counter clockwise rotation by an angle & about the point (xp.T2 010 xp yp1 001 xpyp1 cos sin 0 sin cos 0 xp cos yp sin xp xp sin yp cos yp1 Ex.3).
T 010 010 2 1 11 111 We have cos 45 sin 450 R sin 45 cos 450 001 the standard formula. yp = 1 = 45 T1 100 100 .Soln. click “print”. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . simply open the document you want to convert. Compatible across nearly all Windows platforms. Here xp = 1. 1 / 21 / 2 0 1 / 21 / 2 0 001 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.
5 2 5 2 1 1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.T 1 .[ T 1 .T 2 cos sin 0 sin cos 0 xp cos yp ngvalueswe get sin . Compatible across nearly all Windows platforms.T 2 1 / 21 / 2 0 1 / 21 / 2 0 2 1 / 2 1 / 1 2 1 / 2 11 1 / 21 / 2 0 1 / 2 1 / 2 0 2 11 1 1 A A . R . 1 2 C [ T 1 . R .T 2 ] [ 551 1 / 2 1 / 2 0 ] 1 / 21 / 2 0 2 11 1 2 5 2 1 5 2 5 2 2 11 5 B C 1 1 8 1. R . simply open the document you want to convert.T 2 ] 1 / 2 1 / 2 0 21 / 2 0 1 / [ 431 ] 21 / 2 0 1 / 1 2 11 3 4 3 4 1 2 2 2 2 1 C 1 2 11 2 11 1 2 1. xp xp sin yp cos yp 1 Substituti T 1 .1 B 1 B [ T 1 . T 2 ] [ 231 1 / 2 1 / 2 0 ] 1 / 21 / 2 0 2 11 1 3 2 1 2 1 2 3 2 3 2 2 11 A 1 2 1 . select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . R . R . click “print”.
REFLECTION & SHEAR Besides the 3 basic transformations. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . there are some other transformations which are useful in certain applications. 4. We can choose an axis of reflection in the xy plane or perpendicular to the xy plane.4. click “print”. simply open the document you want to convert. Compatible across nearly all Windows platforms.1 REFLECTION A reflection is a transformation that produces a mirror image of an object relative to an axis of reflection. Two such transformations are Reflection & Shear. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.
2 SHEAR A transformation that slants the shape of an object is called the shear transformation. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. simply open the document you want to convert. click “print”. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .COMMON REFLECTIONS 4. Compatible across nearly all Windows platforms.
but changes the y values which causes horizontal lines to transform into lines which slope up as down as shown in figure.2. One shift x coordinate values and other shifts y coordinate values. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 4. The transformation matrix for x shear is given as 4. The transformation matrix for y shear is given as 1Shy 0 Y _ sh 010 001 X1 X & y1 y YshX . Compatible across nearly all Windows platforms.2 Y SHEAR The Y shear preserves the x coordinate.1 X SHEAR The x shear preserves the y coordinate but changes the x values which causes vertical lines to the left or right as shown below. simply open the document you want to convert. click “print”.2. Two common sharing transformations are used. In both cases only one coordinate (x or y) changes its coordinate while the other preserves it. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
1). select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . Compatible across nearly all Windows platforms.0).5 relative to line yref = 1 b) Shear parameter of 0. click “print”.3 Shearing Relative to other Reference Line We can apply x shear & y shear transformations relative to other reference lines. 100 Sh x 10 sh x .1) as below. 1. B(1. y 1 Sh y 0 010 0 Sh Xshearwith yreference line ref 01 1 yshearwith xreference line y x ref a) Soln.4. simply open the document you want to convert. Here Shx = 0. Transformation matrices are Ex. In x shear transformation we can use y reference line & in y shear transformation we can use x reference line. a) Shear parameter value of 0.5 relative to line xref = 1.5 and yref = 1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Apply the shearing transformation to square with A(0.0). C(1.2. D(0.
select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 5 .5 .A B C D 1 1 1 A B C 1 D 100 Sh 10 Sh . click “print”.1 ) pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 510 0 . simply open the document you want to convert. 100 0 .Y ref 01 001 101 111 011 A 1 [ 0 B C D 1 [ 1 . 0 ) D 1 1 ( 2 . 500 [ 211 111 1 1 1 A B 1 ( 0 .1 ) ( 1 .0 ) C (1 . 501 501 ] ] ] ] x . Compatible across nearly all Windows platforms.
51 . Compatible across nearly all Windows platforms. 51 ( 0 . 5 ) 1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. click “print”. 510 0 . 51 ( 1 .5 and Xref = 1 A B C D 1 1 1 001 101 111 011 00 111 121 01 1 A B C D 1 Shy 010 0 0 Sh X 1 y ref . 50 10 0 .1 ) A B C D 1 1 1 (1 .b) Here Shy = 0. simply open the document you want to convert. 5 ) . 50 . 2 ) ( 0 . 0 .1 . select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
The sequence of basic transformation involves series of rotation and scaling transformation. simply open the document you want to convert. The shear transformation matrix for x and y can be combinely given as 0 1 Shy Shx 10 001 We have the scaling and rotation matrix as S x 00 sin cos sin 0 S y 0 R cos 001 001 If we combine scale matrix & rotation matrix we have S 0 0 S x Cos S x Sin 0 S . Soln.Sy Sin Shy = Sx Sin SxCos = 1 SyCos = 1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . click “print”.NOTE:.It is important to note that shearing operations can be expressed as sequence of basic transformations. matrix we have Shx = . R S y Sin S y Cos 0 001 Comparing shear matrix & S. Ex. Show how shear transformation may be expressed in terms of rotation & scaling. Compatible across nearly all Windows platforms. R.
Compatible across nearly all Windows platforms. Sx S y 1 and cos 1 cos 1 cos 1 cos Substituting values for Sx & Sy we get. Sh Sh x Sin tan y Sin tan The shear transformation matrix expressed in terms of rotation & scales is 0 1 tan tan 10 001 S x Cos AngleofRot S y Cos 1 ation S S x xscale yscale y pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. click “print”. simply open the document you want to convert. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
Such a box is called Window. In a map. the viewing transformation maps picture coordinate in the WCS to display coordinates in PDCS. The Viewing Pipeline If an object is too complex to be shown entirely or we are particularly interested in just a portion of it. we would like to imagine a box about a portion of the object and display what is enclosed in the box. This gives the effect of looking at the image through a window. However when the picture is displayed on the display device it is measured in physical device coordinate system (PDCS) corresponding to the display device. 4. 2D viewing function. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. window to view part coordinate transformation. Sutherland / Cohens line clipping algo. rotation. 2. clipping operations. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . reflection etc to generate a variety of different views of a single picture e. VIEWING TRANSFORMATION A picture is stored in the computer memory in WCS WORLD COORDINATE SYSTEM. CLIPPING The remaining portion which are not of immediate interest must not be visible. we might be interested in the northern region only. 3. Compatible across nearly all Windows platforms. line dipping. click “print”. This mapping of coordinates is achieved with the use of coordinate transformation known as viewing transformation i. We can use variety of transformations like scaling. viewing coordinates reference frame.6 2D VIEWING Viewing pipeline. Sutherland/Hodgeman polygon clipping algorithm.g. simply open the document you want to convert. The process of selecting and viewing the picture is called windowing.e. or any other picture. port clipping. The technique to do so is called ‘CLIPPING’ The process of discarding the portion of a picture which is outside the window (in which we are not interested) is called CLIPPING. Therefore displaying an image of a picture involves mapping the coordinates of the points and lines that form the picture into the appropriate physical device coordinate where the image is to be displayed. 1. a map. in such a case we need some method do display only those portions of the drawing that are of immediate interest. polygon clipping algo.
Relation between the window coordinate and viewport coordinate Once we know the extend of the image in the window. An area on the display device / screen to which a window is mapped is called Viewport. if a coordinate position is at the centre of a window. A window defines what is to be viewed and the viewport defines where it is to be displayed. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . In terms of coordinates it refers to the World Coordinate area for display. While transforming the description from the window to the viewport we have to maintain a relative placement of the object i. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. It might happen that we don’t wish to use the entire screen for display. click “print”. Compatible across nearly all Windows platforms. Such a box on the screen is called Viewport. Xv Xv min Xv max Xv min Xw Xw min Xw max Wx min The window defined is the world coordinate is transformed to viewport coordinates by performing the following steps. it should be displayed at the centre of the viewport. When we change the window parts of the object at the same position on display. simply open the document you want to convert. 5. we need to defiune or select the extend of the viewport.e. we would like to image a box on the screen and have the image confined to that screen.
2) The object together with its window is translated until the lower left corner of the window is at the origin. 3) The object and the window are scaled until the window has the dimensions of the viewport. Compatible across nearly all Windows platforms. simply open the document you want to convert. click “print”. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 4) Translate the viewport to its correct position in the screen pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.1) The part of the object to be displayed is selected in the window.
The transformation is given as W = T. simply open the document you want to convert. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . Compatible across nearly all Windows platforms.S. click “print”.T1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.
2D CLIPPING pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.100 T 010 X w min Y w min 1 S x 00 S 0 S y 0 001 Sx Sy X v max X v min X w max X w min Y v max Y v min Y w max Y w min 100 010 T1 X v min Y v min 1 100 S x 00 100 0 S 0 010 W T . Compatible across nearly all Windows platforms. simply open the document you want to convert.S . select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . click “print”.T1 010 y 001 X v min Y v min 1 X w min Y w min 1 S x 00 0 S y 0 X v min X w min S x Y v min Y w min S y 1 6.
If both endpoints of line are outside the window the line is not necessarily completely outside. All this is done by following certain algorithms. above or below the window. left. 6. The portion of the picture inside the window should be displayed and the other areas should not be displayed. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms. The process allowing the unwanted / invisible portion of the picture to be discarded is called CLIPPING. 7. lines or portions of the lines be within the window. If both the endpoints are completely to the right. LINE CLIPPING The lines are said to be interior to the clipping window & hence visible if both end points are interior to the window. All others are discarded. These lines are retained for display. then the line is completely exterior to the window & hence invisible. The technique used to do so is called CLIPPING. The clipping algorithm determines which points. click “print”. It requires the calculation of intersection points to decide the visible portion of them. POINT CLIPPING The points are said to be interior to the clipping window if Xwmin X Xwmax and Ywmin Y Ywmax The equal sign indicates that points on the window boundary are induced within the window. simply open the document you want to convert.
Find the region codes for each point & identify whether the line is completely visible.g. The four bit codes are called region codes or outcodes. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . Once we have established the region codes for all the line endpoints we can determine which lines are completely inside the clipping window & which are clearly outside. This algorithm uses a four digit (but) code to indicate which of the nine regions contain the end points of line. The lines which cannot be identified as completely inside or outside the window by these tests are checked for intersection with window boundaries. simply open the document you want to convert. This is done through logical AND operations. the line is completely outside the clipping region and if both points are inside the window the line is completely outside & is visible. e. click “print”. If the result of AND operation is not 0000. partially visible or completely invisible. Compatible across nearly all Windows platforms. Consider the clipping window & the lines shown in fig below. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.SUTHERLAND & COHEN SUBDIVISION LINE CLIPPING ALGORITHM It is one of the oldest and most popular line clipping algorithm developed by Dan Cohen and Ivan Sutherland.
the intersection point P1 is found and we get 1 1 the 2 line segments P1P1 & P1 P2. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . simply open the document you want to convert. The line is now 1 reduced to the section from P1 to P2. b) Starting with P1. Again the line 1 1 segment is divided into 2 segments giving P1 P2 &P21P2. Compatible across nearly all Windows platforms. e) For P2 P2 one endpoint P2 is outside the window & thus the 1 line segment P2 P2 is discarded. Visible Comp.Line P1P2 P3P4 P5P6 P7P8 P9P10 Line Point Codes 0000 0000 0000 0001 0001 0001 0001 0000 0000 0100 0010 0000 1000 0010 0000 Logical AND Result Comp. 1 d) Since P2 is outside the window. c) We know that for P1P1 one endpoint P1 is outside the window & 1 thus the line segment P1P1 is discarded. The remaining part of the 1 1 line segment P1 P2 is completely inside the clipping window & hence made visible. 1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. a) The line P1P2 is partially visible. it is checked again for 1 boundaries and intersection pt P2 is found. Then the remaining part of the line is checked against the other boundaries & the process is continued until either the line is totally discarded as a section is found inside the window. click “print”. Invisible Partially Visible Partially Visible Partially Visible The Sutherland Cohen algorithm begins the clipping process for partially visible line by comparing an outside endpoint to a clipping boundary to determine how much of the line can be discarded.
a) If the region codes for both the end points are non zero. Compatible across nearly all Windows platforms. Check for visibility of line P1P2 a) If region codes for both endpoints are zero. y1) P2(x2. 2. Read the 2 line endpoints P1(x1. 8. y1) & P2 (x2. 3. find intersection points 1 P1 & P1 with boundary edges of clipping window with respect to point P1 & point P2 respectively. y2) is Y = m(x – x1) + y1 or y = m(x – x2 ) + y2 wherem y x 2 2 y1 slopeoflin x1 e SUTHERLAND & COHEN SUBDIVISION LINE CLIPPING ALGORITHM 1. then line is completely visible. 7. Assign region codes for nine region to find out which region has the end pts. Draw the remaining line segments. 6. draw the line & go to step 9. click “print”. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 4. Reject the line segment if any one endpoint appears outside the clipping window. b) If the region codes for endpoints are not zero and logical ENDing of them is also nonzero then the line is completely invisible so reject the line and go to step 9. The equation for line passing through points P1 (x1. 1 b) If region code for anyone end point is non zero then find intersection point P1 as 2 P2 with the boundary edge of the clipping window with respect to it. Determine the intersecting edge of the clipping window by inspecting the region codes of 2 end points. Hence. 5. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. y2) Read the coordinates of window. simply open the document you want to convert.The intersection points with a clipping boundary can be calculated using the slope intercept form of the line equation. Divide the line segments considering intersection points. c) If the region codes for the 2 end points do not satisfy the above conditions a) & b) then line is partially visible.
SUTHERLAND – HODGEMAN POLYGON CLIPPING A polygon can be clipped by processing its boundary as a whole against each window edge. To achieve this we require an algorithm that will generate additional line segment which make the polygon as a closed area. when a closed polygon is clipped as a collection of lines with the line clipping algorithm. simply open the document you want to convert.9. Stop. cd. 9. Ij are added to polygon description to make it closed. The lines ab. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. gh. click “print”. We consider a polygon as a closed solid area. However. POLYGON CLIPPING Polygon is a collection of lines. the original closed polygon becomes one or more open polygon or discrete lines. de. fg. Therefore we might think that the line clipping can be used directly for polygon clipping. Compatible across nearly all Windows platforms. This is achieved by processing all polygon vertices against each clip rectangle boundary is turn. Thus we need to modify the line clipping algorithm to clip to clip polygon. Hence after clipping it should remain closed. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
simply open the document you want to convert. At each step a new set of polygon vertices is generated and passed to the next window boundary clipper. Compatible across nearly all Windows platforms. Beginning with the original set of polygon vertices. The new set of vertices could then be successively passed to a right boundary clipper. we could first clip the polygon against the left rectangle boundary to produce a new sequence of vertices. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. click “print”. This is the fundamental idea in the Sutherland Hodgeman algorithm. a top boundary clipper & a bottom boundary clipper as shown in fig.
[DIAGRAM] 2. Compatible across nearly all Windows platforms. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . This is achieved by processing 2 vertices of each edge of the polygon around the clipping boundary or plane. only the second vertex is added to the output vertex list. If the 1 vertex of the edge is inside the window boundary and the second vertex of the edge is outside. click “print”. the window boundary and the second vertex of the edge is inside then intersection point of the polygon edge with the window boundary & the second vertex are added to the output vertex list. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 1. The output algorithm is a list of polygon vertices all of which are on the visible side of the clipping plane. If the first vertex of the edge is outside. st 5. 3. If both the vertices of the edge are inside the window boundary. simply open the document you want to convert. If both the vertices of the edges are outside the window boundary nothing is added to the output list. 4. only the edge intersection with the window boundary is added to the output vertex list.
Once all the vertices are processed for one clip window boundary. PROBLEMS IN TRUE CURVE GENERATION APROACH 1. Save the resulting intersections & vertices in the new list of vertices according to 4 possible relationships between the edge and the clipping boundary. To specify a curve we need more information than just endpoints. 2. 7. Compatible across nearly all Windows platforms. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. 5. 1) The first approach lies the Curve Generation Algorithms line midpoint circle to midpoint ellipse algorithm to draw curved lines. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . In this case only true curves can be drawn. Read coordinates of all vertices of the polygon. 3. Determining the intersection of the polygon edge and the clipping plane. Determining the visibility of a point or vertex (Inside – Outside Text) & 2. individually with the clipping plane. Sutherland Hodgeman Clipping Algorithm 1. Read coordinates of the clipping window. Each time the resultant list of vertices is successively passed to process the next edge of the clipping window. CURVE GENERATION TECHNIQUES There are 2 approaches to draw curved lines. 1. Stop. 2) In the second approach curved lines are approximated by a no of small straight line segments with the help of interpolation techniques. simply open the document you want to convert. 4. Repeat the steps 4 & 5 for remaining edges of the clipping window. Going through the above 4 cases we can realize that there are two key processes in this algorithm. Compare the vertices of each edge of the polygon. the output list of the vertices is clipped against the next window boundary. click “print”. Consider the left edge of the window. 6.
INTERPOLATION TECHNIQUES 1. LAGRANGE’S CURVE GENERATION TECHNIQUE The main task in this process is to find a suitable mathematical expression for the known curve. Polynomial function in the parametric form is given as x = fx (u) y = fy (u) z = fz (u) pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. BSpline curve generation technique In practice. click “print”. The gap between the curve and rest of the sample points can be filling by calculation coordinate values along the known curve and joining them by small straight line segments as shown in the figure above.2. But polynomial functions are preferred. 1. simply open the document you want to convert. Compatible across nearly all Windows platforms. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . There are polynomial. Using this approach only true curves like circular or elliptical are can be generated and is not suitable for drawing other curves like wings or human faces. Bezier generation technique 3. we have to deal with some complex curves for which no direct mathematical expression is available. Lagrange’s Interpolation technique 2. trignometric. then we can draw the required curve by filling the region with known sample point by pieces of true curves which pass through the sample points. Such curve can be drawn using approximation techniques. ] If we have a set of sample points of the unknown curve. exponential and other classes of function which can be used to approximate the curve.
select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .. In other words each sample point tries to pull the curve in its own direction and the function Bi(u) gives the strength of the pull. the expression for the curve passing through sample points can be realised as: x = x1B1(u) + x2B2(u) + x3B3(u) + .z = z1B1(u) + z2B2(u) + z3B3(u) + . In general the ith value of Blending function for other integer values is given as Bi (u ) (u 1)u (u 1) [u (i 3)][u (i 1)] [u (i n)] (i 1)(i 2)(i 3) 1(1) (i n) Using the Blending function. n f x (u ) x i B i (u ) i 1 n f y (u ) y i B i (u ) i 1 n f z (u ) z i Bi (u ) i 1 Bi(u) is called the Blending function. BEZIER CURVE GENERATION TECHNIQUE This is the second approach for curve generation developed by French Engineer Pierre Bezier... Ex. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. of control points. of control points. one term for each sample point. 4 points generate a cubic polynomial.... 2. simply open the document you want to convert. Bezier curve can be filled into any no... of control points... 3 points generate a parabola. As a rule.y = y1B1(u) + y2B2(u) + y3B3(u) + . click “print”. Compatible across nearly all Windows platforms.We have to construct the function as sum of terms.. For each value of parameter x the function Bi(u) tells how much the current sample point affects the curve. the degree of polynomial of the Bezier curve is one less than the no. The degree of polynomial of the Bezier curve is determined by the no..
B. click “print”. thus we get 4 curves from the original Bezier Curve. 1) 2) 3) 4) 3. Then their midpoints (ABC. It is widely used in CAD systems. The continuous curve of Bspline is defined by control points. simply open the document you want to convert. C. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. The lines joining the 4 connecting points (A. BC. ABC & ABCD as the control points for first section and point ABCD. CD) Then their midpoints (AB. By considering the 2 sections separately. Bezier curve has a no. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . D) are determined (AB. AB. the curve is divided into 2 more sections. CD) are determined & connected by line segments. midpoints are connected and their midpoint ABCD is determined. of properties which makes it useful and convenient for curve and surface design. Compatible across nearly all Windows platforms. divides the Bezier curves into 2 sections. We use the midpoint approach for Bezier Curve. This process can be repeated on the curve can be split into smaller sections until use how sections so small that they can be replaced by straight lines. BCD) are determined. BCD. CD & D as control points for second section. BSPLINE CURVE GENERATION TECHNIQUE Spline is a tool made of thin flexible strip of metal or rubber used by draftsmen to aid in drawing curved lines. This makes point A. The point ABCD. BC. Finally.
scaling & rotation. simply open the document you want to convert. What is Computer Animation? Ans. We can write a general expression for the calculation of coordinate position along a B spline curve in a Blending function formulation as n P u Pk Bk . colour. d BSpline Blending function which is a polynomial of degree d – 1 D can be any integer value between 2 & n + 1 Blending functions for BSpline curves are defined by Can – De – Boor recursion formula. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. click “print”. d (u ) u uk u d u Bk . While the curve is shaped by control points. 2. etc. It is defined as a time sequence of visual changes. computer generated animation can display time variations in object size. Computer animation can also be generated by changing the camera parameters such as position. Q. it may or may not pass through all control points. d 1(u ) uk d 1 uk u k d u k 1 COMPUTER ANIMATION Q. orientation & focal length. 1. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . What is segmentation? Ans. texture. d 1(u ) k Bk 1 . Segmentation is the process in which the image related information present in the display file is divided into segments. Bk . Compatible across nearly all Windows platforms. d (u ) 2 d n 1 k 0 Where Pk i/p set of n+1 control points. In addition to changes in position of object by translation. Bk.
Compatible across nearly all Windows platforms. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. simply open the document you want to convert. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . click “print”.
x = cos . vertical cylinder with radius r is taken. Compatible across nearly all Windows platforms. Then x. Another possible arrangement is left handed system. The surface of constant is a vertical plane which contains z axis. Most Graphics packages utilises righthanded system. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . Cylindrical – In this system. z = z pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. simply open the document you want to convert. RightHand Coordinate System Put fingers around the z axis and the thumb should point the positive direction of z axis. click “print”.7 INTRODUCTION TO 3D 3D Coordinate System – The figure shows three dimensional cartesian coordinate system. y and z are given as. y = rsin . This is called as righthanded system because righthand thumb points in positive z direction. The surface of the constant z is horizontal plane which will be parallel to xy plane.
The diagram shows these directions and also the display planes. The object coordinates are transferred to the display plane coordinates and are projected onto the display plane.Spherical – The surface of constant r is a sphere. simply open the document you want to convert. Let us take a 3D object and let us show the different two dimensional views on different display planes. Compatible across nearly all Windows platforms. The following diagram shows 3D object and its views from two different directions. different visible points are mapped onto the display plane to obtain different two dimensional views. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. click “print”. From the diagram. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . The surface with constant is a cone which is having apex at origin. x = rcossin y = rsinsin z = rcos 3D Display Techniques To obtain a display of three dimensional scene. we must set a view plane or display plane. The surface of constant is a vertical plane which contains z axis. By selecting different viewing positions. Parallel Projection – One method of generating a view of solid object is to project points on the object surface along parallel lines onto the display planes.
In this method. Compatible across nearly all Windows platforms. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. simply open the document you want to convert. In perspective projection. This is more realistic. the objects away from viewing position are displayed smaller than the objects of some size which are near to the viewing position. parallel lines in a scene are not parallel on the display plane. click “print”. because that is how our eyes understands any scene.Perspective Projection – Another method for generating a view of three dimensional scene is to project points to the display the plane along converging paths. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
click “print”. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. it is difficult to decide whether the object is like diab or diac. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . because from this information we can decide which is front and which is back of the displayed object. Surface Rendering – Realistic images can be obtained by shading different surfaces with different intensities. Using RayTracing. Depth cuing can be applied by deciding maximum and minimum intensity values. the internal details of an object can be shown. Viewing Pipeline – The following figure shows the general steps to be followed for 3D viewing of the object. transparent by illuminating objects with different styles. simply open the document you want to convert. Cutway Views – The objects can be defined by hierarchical structures. The objects can be shown as shiny.Depth Cuing – Knowing the depth information of the object is important. Compatible across nearly all Windows platforms. There are different methods to give 3D effects. In depth wing. From diaa. the lines which are closer to view position are displayed with more intensity and lines away from view position are displayed with decreasing intensity. by cutting the object into different pieces. so that. the shiny surfaces are displayed. also gives the appearance of removal of hidden lines without actually removing them. Visible line and Surface identification – The visible lines and surfaces can be identified by the algorithms. Applying shading to visible surfaces. Draw nonvisible lines as dashed lines or simply remove nonvisible lines. Display visible lines in different color or highlight them.
The conversion of modeling coordinates of the object into the world coordinate system is referred as Modeling Transformation. Once the object is transferred into the world coordinates, it will be then transferred into viewing coordinates. The process used to carry it out is referred as viewing transformation. The viewing coordinate system is used as a reference for specifying observer’s position. The viewing coordinates available in 3D coordinate system are to be projected on 3D projection plane. The process is called as projection transformation. The projection coordinates, are finally mapped to device coordinates using Workstation transformation.
The XwYwZw specifies the world coordinate system. The object to be viewed is as shown. The P0 (X0, Y0, Z0) in the world coordinate system specifies the origin of the viewing coordinate system XvYvZv. Viewing Coordinates Generating a view of an object in three dimensions is similar to photographing the object. We can walk around the object and take its picture from any angle, at various distances and with camera orientations. Whatever appears in the viewfinder is projected onto the flat film surface. The size of the camera lens determines which part of the object appear in the final picture. The ideas will be similar in the 3D viewing system. A particular view of the object is selected by establishing the viewing coordinate system. It is also called as view reference coordinate system. A view plane or projection plane, is then set up perpendicular to the viewing Zv axis.
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
A particular point P0 (X0, Y0, Z0) in the world coordinate system is selected as origin of viewing coordinate system. The point P0 will then be nothing but the reference point for viewing. The object is then to be converted from world coordinate system to viewing coordinate system, for projection.
Transformation from World Coordinates to Viewing Coordinates – Before object details can be projected to the view plane, they must be transferred to viewing coordinates. Conversion of object details from world to viewing coordinates is equivalent to transformation that superimpose the viewing reference frame onto the world frame. This transformation will require sequence as, 1) Translate the view reference point to the origin of the world coordinate system. 2) 3D rotation required to coincide xvyvzv with xwywzw. 3) All the back rotations required to bring xvyvzv at its original orientation. 4) Back translation to bring xvyvzv at its original position. The first step will require translation with Tx = x0, Ty = y0 & Tz = z0 The second step will require Rx(x) followed by Ry() as that of in 3D rotation (chap – 7). The third step will require Ry() followed by Rx(x) as that of in 3D rotation (chap – 7). The fourth step will require back translation with Tx = x0, Ty = y0 & Tz = Z0.
Projections – Once the world coordinates are converted into view coordinates then the three dimensional object can be projected onto two dimensional plane (view plane). There are two basic methods of projection. a) Parallel Projection b) Perspective Projection Parallel Projection –
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
In parallel projection, coordinate positions are transformed to a view plane along the lines which are parallel. A parallel projection can be defined with the projection vector Vp which defines direction of projection lines. If projection vector is perpendicular to view plane, then the parallel projection achieved is called as orthographic parallel projection.
If projection vector is not perpendicular to view plane, then oblique parallel projection is achieved.
The transformation equations for orthographic parallel projection are simple. If the view plane is placed at position Zvp along the Zv axis then (x, y, z) in viewing coordinates is transformed to projection coordinates as, xp = x yp = y zp = zvp
pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms, simply open the document you want to convert, click “print”, select the “Broadgun pdfMachine printer” and that’s it! Get yours now!
original z coordinates are stored for depth information. From the diagram. Oblique Parallel Projection – In the diagram. Compatible across nearly all Windows platforms. click “print”. xp = x + Lcos yp = y + Lsin and tan L Z. y) is the point corresponding to (x. Z L 1 L Z tan 1 1 ZL1 whereL1 tan tan xp x zL1 cos yp y zL1 sin Any parallel projection can be defined as. simply open the document you want to convert. = y0 0 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. y. z) if orthographic parallel projection would have been done. The (x. 1000 0100 [ X p Y p Z p 1] [ xyz1] L1 cos L1 sin 00 00 Z v p 1 When orthographic projection is done. x is the angle made by projection vector from (x. z) to view plane.1000 0100 [ x p y p z p 1] [ xyz1] 0000 00 z v p 1 However. y. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
u will be given as. simply open the document you want to convert. The projection reference point lies on zv axis. y p y. click “print”. z ) = (x. zprp). z ) = (0. then (x . y1. 1 1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. z p z conditionsfororthographic L1 Perspective Projection – Following diagram shows the perspective projection from projection reference point. Compatible across nearly all Windows platforms. we can transform points along projection lines which meets project reference point Zprp along Zv axis and view plane is placed at zvp. On the view plane.) To obtain perspective projection of three dimensional objects. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .1 0 tan x p x. The coordinate positions can be defined in parametric equations along projection line. y. 0. z) 1 1 1 whereas when u = 1 then (x . (The objects of same size at different distances from view planes produces different sizes of projected images in perspective projection. y . 1 x = x – xu 1 y = y – yu 1 z = z – (zprp) u The parameter u can take value from 0 to 1. When u = 0.
y & z we get. for display an output device. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .and 3D viewing – An algorithm for three dimensional clipping identifies and saves all surface segments within a view volume. Lines which are partially inside are intersected with the volume boundary planes and the part which is inside the volume boundary is displayed. Lines which are completely inside the selected volume boundary. The parts which are outside the view volume are discarded. click “print”. Instead of clipping against 2D window. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Compatible across nearly all Windows platforms. clipping of object is done against the boundary planes of the view volumes. are selected. The orthographic projections are not affected by plane position because projection lines are parallel and are perpendicular to view plane. The perspective projection is affected by relative position of object and view plane. z prp z and z p z vp Thus projection point on the view plane can be calculated. z prp z Similarly.u z vp Z z prp Z 1 1 1 By substituting this value into the equation of x . Clipping. Lines which are totally outside the volume boundary are discarded. Oblique parallel projections are affected by position of view plane. because angle of projection vector with view plane can change. Clipping in 3D is achieved by extending the ideas of twodimensional clipping. z prp z vp y p y. z vp z x1 x p x x z prp z z prp z z vp z x z prp z z prp z vp x p x. simply open the document you want to convert.
The factors Dx. y = 0. click “print”. x = 1. Dx Dz y v min xv max x v min y D y v max x w max x w min y w max y w min z v max z v min z w max z w min where( xv min .0) ( xv max .1) xv = xvmin + (xw_xwmin) Dx yv = yvmin + (ywywmin) Dy zv = zvmin + (zwzwmin) Dz (extension of 2D window to viewport clipping). z = 0. z v min ) (0. which is normalized view volume. The normalized view volume is a region defined by the planes x = 0. The objects are now processed against planes instead of lines. simply open the document you want to convert.0. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. z v max ) (1. The objects in the view volume in world coordinates are transformed to unit cube (volume viewport). y v min . Dy and Dz are the ratios of the viewport and regular window view volume.Normalized view volumes for clipping & viewport clipping – The rectangular parallelopiped in world coordinate system is mapped into the unit cube. y v max . select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .1. Lines and polygons in a scene are clipped against viewport boundaries with procedures similar to two dimensions. z = 1. Compatible across nearly all Windows platforms.
select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .The two dimensional concept of region codes can be extended to three dimensions. If value of u is between 0 and 1 then there exists intersection and intersecting point will be given as follows. bit0 = 1 if x < xvmin (left) bit1 = 1 if x > xvmax (right) bit2 = 1 if y < yvmin (below) bit3 = 1 if y > yvmax (above) bit4 = 1 if z < zvmin (back) bit5 = 1 if z > zvmax (front) If the endpoint is inside the clipping volume. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. z) is specified in parametric equation form as follows. In LiangBarshy algorithm. Instead of 4 bit code. then the code will be 000000. One bit for front of the unit volume and one bit for the back of the unit volume. If the above conditions are not satisfied then the line is intersected with necessary planes out of the 6 planes of the view volume. simply open the document you want to convert. For each endpoint of the line the 6 bit code will be developed. After intersection. code of 6 bits will be developed. the part of the line outside the view volume is discarded. If both the endpoints has the codes as 000000. The bits are as follows. x = x1 + (x2 – x1)u y = y1 + (y2 – y1)u 0u1 z = z1 + (z2 – z1)u Let us consider a case in which line is to be intersected with a plane say z = zvmin. Compatible across nearly all Windows platforms. any point (x. Then the value u is found as u z v min z1 z 2 z1 If the value of u is not in the range of 0 u 1 then it means line is not intersecting with the plane z = zvmin. then the line is selected for display. If there is 1 at the same position in the two codes then the line is completely outside the view volume and hence rejected. y. click “print”. use parametric equations. To find intersection of a line we will.
z z1 x x1 ( x 2 x1 ) v min z z 2 1 z z1 y y1 ( y 2 y1 ) v min z z 2 1 z z v min . intersections with remaining 5 planes can also be determined. Similarly. Compatible across nearly all Windows platforms. click “print”. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . simply open the document you want to convert. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.
Most of the algorithms are of imagespace methods. Let us rearrange the equations as. such as surface rendering. The two different approaches are objectspace methods or imagespace methods. visible surface detection. The equation of the plane surface is given by. it is important to identify visible and invisible parts of the scene. it is necessary to know plane equations. transformation. The algorithms used to identify this are called as visible surface detection methods or hiddensurface elimination methods. B. (x1. z3) on the plane. y3. Visible surface detection algorithms are broadly classified according to the way of working. C and D. Plane equations – In 3D applications. An objectspace method compares the objects and parts of the object with each other within the scene definition. to determine visible surfaces. (x2.8 VISIBILITY Z BUFFER ALGORITHM While generating realistic graphics display. simply open the document you want to convert. Ax + By + Cz + D = 0 Where. A. Compatible across nearly all Windows platforms. (x. C and D are unknown. These three points will form simultaneous equations as. y2. visibility is decided pixel by pixel at each position on the projection plane. we must know A. B. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . z1). Ax1 + By1 + Cz1 + D = 0 Ax2 + By2 + Cz2 + D = 0 Ax3 + By3 + Cz3 + D = 0 In the above equations. Let us take three points. z2) and (x3. To know the above equation of the plane. y. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. z) is any point on the plane. y1. In an imagespace method. click “print”.
BACKFACE Detection – This is a fast and simple object space method which is used for identifying the back faces of the object. click “print”. the point (x. Compatible across nearly all Windows platforms. z ) is “inside” the given plane then. z) is inside the surface If Ax + By + Cz + D > 0. the point (x. when viewing the surface in an outsidetoinside direction. y. y. C and D are calculated using vertices selected in anticlockwise order. simply open the document you want to convert. In righthanded coordinate system. of (x . provided the plane parameters A. A B c x1 y1 z1 1 D D D A B C x 2 y 2 z 2 1 D D D A B C x 3 y 3 z 3 1 D D D 1y1 z1 x1 1z1 1y 2 z 2 x 2 1z 2 x1 y1 1 x2 y 2 1 x3 y 3 1 A 1y 3 z 3 B x3 1z 3 C x1 y1 z1 D x1 y1 z1 D x1 y1 z1 D x2 y 2 z 2 x2 y2 z 2 x2 y 2 z 2 x3 y 3 z 3 1 y1 z1 1y3 z3 x3 y 3 z 3 x 11z1 x3 1z 3 x3 y 3 z 3 x1 y11 x3 y 3 1 x1 y1 z1 x3 y 3 z 3 A 1 y 2 z 2 B x 2 1z 2 C x 2 y 2 1 D x 2 y 2 z 2 For any point. This method is based on the equation of the plane. we have Ax + By + Cz + D 0 We can identify the point as either inside the plane or outside the plane. B. not on the plane with parameters A. If Ax + By + Cz + C < 0. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . y1. accordint to sign. B. D. z) is outside the surface These inequality tests are valid in righthanded cartesian system. C. 1 1 1 Ax + By + Cz + D < 0 1 1 pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.
if c < 0 then the Normal Vector points away from view position. This is because. if viewing direction is along ‘‘ve Zv axis. For every pixel (x. In the above diagram. The surface with normal N2 is considered to be frontface and hence it is to be displayed. Compatible across nearly all Windows platforms. Consider the following diagram. In this method. one point at a time across the surface. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . One is used to store depth values for each (x. The point with lowest depth will be selected for display. For this algorithm. y) as shown in the diagram. usually.The equation of the plane is determined by taking three points on the plane in anticlockwise direction when looking from “outside” to “inside”. y) on the view plane. DepthBuffer (zbuffer) method – The depth buffer method is commonly used imagespace method. he depth is measured from view plane along zaxis. click “print”. Each point (x. two buffer areas are required. This method is called as zbuffer method. In right handed system. and hence it will be decided as back surface / back face. simply open the document you want to convert. surface depths are compared at each pixel position on the projection plane. used to detect the visible surfaces. z) on the surface is converted to projection coordinates (x. component C1 of N1 will be negative whereas component C2 of N2 will be positive and hence surface with normal N1 is a backface and hence it is to be removed while displaying. Each surface of a scene is processed separately. object depths can be compared by comparing z values. y) pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. y. then C is the component of normal to the surface which will be parallel to Z axis.
y) Then set depth (x. Depth values for a position (x. 1. Ibackground is background intensity. Calculate the z value for each (x. A( x 1) By D Ax By D A C C C A z1 z C z1 Similarly. y) = Ibackground 2. (x+1. y) is intensity of a point (x. then the depth z of the next position along the same scan line i. y) is obtained as. Compatible across nearly all Windows platforms. y) position on the surface. compare depth values to previously stored values in the depth buffer to determine visibility. click “print”.position and refresh buffer is used to store intensity values/color values for color systems for each (x. y) Isurf (x. the depth buffer contains the corresponding depth values for visible surfaces and refresh buffer contains the corresponding intensity values for these surfaces. depth values for succeeding scan lines can be obtained as follows. simply open the document you want to convert. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . After all the surfaces have been processed. depth (x. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. y) are calculated from plane equation for each surface. y) on the surface. If z < depth (x. For each position on each surface. Initialize the depth buffer and refresh buffer so that for all the positions (x. y) = 1 and refresh (x. Z Ax By D C 1 If the depth of position (x. All the positions of the depth buffer are initialized with 1 and all the positions of the refresh buffer are initialized with background intensity. y) position. y) Where. Isurf (x. The steps of depthbuffer can be written as follows. y) z and Set refresh (x.e. y) has been determined to be z. y) on the view plane.
Compatible across nearly all Windows platforms. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . simply open the document you want to convert. Ax B( y 1) D C Ax By D B z 11 C C B z 11 z C z 11 Thus. click “print”. successive values of depth on a particular surface can be calculated faster.
Design of an Animation Sequence pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents.. we can decide whether to display or not. shear transformation etc. Computer animations can also be generated by changing camera parameters such as position. simply open the document you want to convert. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . Segmentation:In practice. position. We may wish to display an internal plan of the lining room. a computergenerated animation could display time variations in object size. it is included in the active segment list & display file interpreter processes it. T. kinematics & dynamics. The term computer animation generally refers to any time sequence of visual changes in a scene. the segment is also associated with image transformation parameters such as scaling. click “print”. each object has a set of attributes such as size. visibility etc. Along with the attributes. colour. colour.9 COMPUTER ANIMATION Computer Animations. The plan may contain various objects such as sofa set. size.g.V. Raster animations. design of animation sequence. Compatible across nearly all Windows platforms. by setting the visible attribute of the segment. When the visible attribute of segment is D it is not included in the active segment list & display file interpreter ships this segment. Such a segment is called posted segment. Each segment corresponds to a component or object of the overall display & it is associated with a set of attributes. orientation and focal length. We know that all the information about the image is stored in the display file. showcase etc. the image on the display screen is often composed of several pictures or items of information. E. texture etc. rotation. Such a segment is called unposted segment. The display file is divided into segments. morphing motion specification. In addition to changing object position with translations or rotations. When the visible attribute is set to 1. The most common screen attributes of an object are shape. colour & its position in the room.
the associated movements of each object are specified along with the shape. Film requires 24frames per second and graphic sequences are refreshed at the rate of 30 to 60 frames per second. More key frames are specified for complex motion than simple. Within each key frame. Therefore. Objects can be defined in terms of basic shapes such as polygons. Typically. spheres etc. each object is positioned according to time for that frame. time intervals for motion are set up so that there are from 3 to 5 in between frames for each pair of key frames. an animation sequence is designed with the help of the following steps – Storyboard layout Object definition Keyframe specification Generation of inbetween frames Definition of frame :For framebyframe animation. The number of inbetween frames needed is determined by the media to be used to display the animation. It defines the motion sequence as a set of basic events that are to take place. An object definition is given to each participant in the action. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .In general. Raster systems store picture information as pixel patterns in the frame buffer. Depending on the type of animation to be produced. circles. Inbetween frames are file intermediate frames between the key frames. each frame of the scene is separately generated and stored later. In addition. The storyboard is an outline of the action. A key frame is a detailed drawing of a scene at a certain time in the animation sequence. click “print”. some simple transformations can be carried out rapidly by simply moving rectangular arrays of stored pixel values from one location to another within the frame buffer. simply open the document you want to convert. the frames can be recorded on a film or they can be consecutively displayed in “realtime playback” mode. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. arc. the storyboard would consist of a set of rough sketches or it could be a list of the basic ideas for the motion. Raster Animations :On raster systems. we can generate realtime animations in limited applications using raster operations. slowly varying motion. Compatible across nearly all Windows platforms.
of vertices) is same for both frames. click “print”. then we copy the array back into the raster at the new location. of polygon edges (or the no. The bit setting in a rectangular area are copied as a block into another part of the raster. simply open the document you want to convert. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. An edge with vertex positions 1 & 2 in key frame K evolves into two connected edges in key frame K+1. Figure above illustrates translation performer as a block transfer of a raster area. for manufacturing a line segment in key frame k into two connected line segment in key frame k+1. We accomplish this translation by false reading pixel intensities from a specified rectangular area of a raster into an array. Compatible across nearly all Windows platforms. Morphing methods could be applied to any motion or transition involving change of shape. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .Translating an object from screen position (a) to position (b) by moving a rectangular block of pixel values. Coordinate positions Pmin & Pmax specify the limits of the rectangular block to be moved & P0 is the destination reference position. The original object could be erased by filling its rectangular area with background intensities. Given the key frames for an object transformation. we first adjust the object specification in one of the frames so that the no. Morphing :Transformations of object shapes from one form to another is called morphing which is a shortened form of metamorphosis.
of edges to be divided. Lk+1) 2) Ne = Lmax mod Lmin 3) Ne = int (Lmax/Lmin) Where Ne denotes the no. of vertices (& edges) in the two key frames. 1) Lmax = max (Lk. Compatible across nearly all Windows platforms. we add a vertex between vertices 1 & 2 in key frame k to balance the no. 1) Vmax = max (Vk. click “print”. Vk+1) 2) Nes = (Vmax – 1) mod (Vmin – 1) Nes no. of line sections 3) Np = int (Vmax1/Vmin1) Np no. of sections. simply open the document you want to convert. Rules for edges Let Lk & Lk+1 denote line segments in consecutive frames. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Vk+1) Vmin = min (Vk. We can state general processing rules for equalizing key frames in terms of either the no. of points to be added. of edges or the no. Since key frame k+1 has an extra vertex. of vertices to be added to a key frame. A straight line segment in key frame k is transformed into two line segments in key frame k+1. of edges) to Ns+1 sections. of vertices in the two consecutive frames. Rules for vertices :Let Vk & Vk+1 denote the no. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 4) The preprocessing is accomplished by dividing Ne (no. Lk+1) Lmin = min (Lk.Linear interpolation for transforming a triangle into a quadrilateral. Ns denotes the no.
This process is known as hidden surface or hidden line elimination or visible surface determination. Compatible across nearly all Windows platforms. velocity & acceleration) without reference to the forces that cause the motion. We can approximate the path of a bouncing ball with damped rectified line curve. With a kinematic description. we specify the animation by giving motion parameters (position. Visibility:In a given set of 3D objects & viewing specifications. we wish to determine which lines or surfaces of the object are visible. click “print”. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. friction & other mechanical forces. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . y(x) = A  sin (wx+0)  e where A initial complitude w angular frequency 0 phase angle k damping constant These methods can be used for simple user programmed animation sequences. of line sections. Motion specifications:There are several ways in which the motions of objects can be specified in an animation system. Then the geometric transformation matrices are applied to transform coordinate positions.e. Eg. 3) We can also construct animation sequences using kinematic or dynamic descriptions. of points to the no. 2) We can use an approximating equation to specify certain kinds of motions. 1) Motion specifications can be given in terms of translation & rotation parameters i. simply open the document you want to convert. Examples of forces affecting object motion include electromagnetic. we specify the rotation angles & translation vectors. Dynamic descriptions on the other hand require the specification of the forces that produce the velocities & accelerations. so that we can display only the visible lines or surfaces. gravitational.4) Preprocessing using vertex count is performed by adding the no.
one scan line at a time. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . The calculated depth is compared to the value previously stored in the depth buffer at that position. click “print”. Thus object depths can be compared by comparing the zvalues & hence the name zbuffer algorithm. y) pixel position. the new depth value is stored. y. if the calculated depth is greater than the value stored in the depth buffer. Eg. calculating the depth (z value) at each (x. When the object description is converted to projection coordinates (x. each pixel position on the view plane is specified by x & y coordinate & z value gives the depth information. Initially. Compatible across nearly all Windows platforms. simply open the document you want to convert. all positions in the depthbuffer are set to D (minimum depth) & the refresh buffer (frame buffer) is initialized to the background intensity. warnockls algorithm etc. Depth Buffer algorithm: One of the simplest & commonly used image space approach to eliminate hidden surface is the Zbuffer or depth buffer algorithm. y) position as surfaces are processed & frame buffer stores the intensity values for each position. This algorithm compares the surface depths at each pixel position on the projection plane. The surface depths is measured from the new plane along the Z axis of a viewing system. The zbuffer is used to store depth values for each (x. z).Various algorithms are used to find the hidden lines or surface & visible lines or surfaces to an observer located at a specified point in space. The implementation requires another buffer memory called zbuffer along with the frame buffer memory required for raster display devices. Backface removal algorithm. Zbuffer algorithm. & the surface intensity at that position is determined & placed in the same xy location in frame buffer. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. Each surface listed in the polygon tables is then processed.
1. Putpixel plots a pixel in the specified color at a specified point. 5. Compatible across nearly all Windows platforms. Eg :line (100. 1. top Rectangle’s upper left corner right. 4. int thickness). 1) line (100. int y1. putpixel ( ). 100. int x2. int bottom). line draws a line between two specified points. 100. int color). bar draws a filled in rectangular. 200. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . Syntax : pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. simply open the document you want to convert. 100. 300. Syntax :putpixel (int x. int y2). click “print”. unsigned pattern. Set line style sets the current line style and width or pattern. int top. 3. set line style ( ).The output screen is initially set with background colour while & the drawing color (set color) is set to black. Draw a rectangle in current line style. two dimensional bar. 2. 200). thickness & drawing color. int y. 300). rectangle ( ). 400m. 100. Parameters Meanings left. 200). eg:putpixel (300. int right. bar ( ).10 GRAPHICS COMMANDS Note:. 4). bottom Rectangle’s lower right corner Eg :Bar (200. Syntax : setlinestyle (int linestyle. Syntax : bar (int left. eg :setlinestyle (3. Syntax: line (int x1. line ( ).
int y. eg :rectangle (100. eg:arc (100. 200. 10. int bottom). eg: fillellipse (500. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . 9. Compatible across nearly all Windows platforms. 360. 270. circle ( ). simply open the document you want to convert. then fills the ellipse with the current fill pattern. int stangle. int radius). int endangle. int y radious). 7. y center of ellipse x radius Horizontal axis y radius Vertical axis stangle Starting angle endangle Ending angle Eg:Ellipse (500. int x radius. ellipse ( ). y centre coordinates eg :circle (400. Syntax:circle (int x. 0. int y. 0. 100. Syntax:ellipse (int x. Draw a circle in current drawing color. 300. arc ( ). 40). Draws a circular arc in the current drawing color Syntax : arc (int x. fillellipse (int x. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. fillellipse ( ). 200. 20). int y. Draws a pieslice in the current drawing color. pieslice ( ). 8. 50. Draw an ellipse. int right. 300) 6. Parameter Meaning x. 300. 20). int y. rectangle (int left. int top. int radius). 50. int endangle. ellipse draws an elliptical arc. 400. int stangle. then fills it using the current fill pattern & fill colour. 200. click “print”. 100. int y radius). Parameters Meanings x. int x radius. 20).
20). 400. click “print”. 14. 50). 400. 20). setbkcolor ( ). eg:. set color ( ). 12. eg:setfillstyle (1. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! . eg :pieslice (400. int y. “CONGRAGULATIONS”). Compatible across nearly all Windows platforms. Outtext xy ( ). Set the background color to the specified color. int endangle. int color). int y. 300. y) Syntax: outtext xy (int x. simply open the document you want to convert. set fillstyle ( ). int stangle. 13. 400. Syntax: floodfill (int x. 400. 200. Syntax : setcolor (int color).outtext xy (200. pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. int border). char text string). 20). 11. eg: setcolor (4). 360. eg:setbkcolor (4). int radius). 4) circle (400. The area bounded by the color border is flooded with the current file pattern & fill color. setcolor sets the current drawing color. Syntax: setbkcolor (int color). 14). circle (400. Sets the current fill pattern & fill color Syntax: setfillstyle (int pattern. floodfill (400. 270. eg :circle (400. Display a text string in the viewport at the position (x. floodfill ( ). Syhntax : pieslice (int x. unt y. 15.
settextstyle ( ). outtextxy (200. 1.16. simply open the document you want to convert. Compatible across nearly all Windows platforms. Sets the text font. direction in which text is displayed and the size of the character Syntax : settextstyle (int font. click “print”. int char size). 300. 3). “CONGRATS”). pdfMachine A pdf writer that produces quality PDF files with ease! Produce quality PDF files in seconds and preserve the integrity of your original documents. eg settextstyle (1. int direction. select the “Broadgun pdfMachine printer” and that’s it! Get yours now! .
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.