Professional Documents
Culture Documents
Computer Graphics Notes
Computer Graphics Notes
COMPUTER GRAPHICS
SYLLABUS
CHAPTER 1 INTRODUCTION
What is Graphics
CHAPTER 2 ALGORITHMS
algorithm, frame buffers, Circle & ellipse generating algo, midpoint circle alg., midpoint
(sine & cos rotation), homogeneous rotation & translation, Rotation about on arbitrary
window to view part co-ordinate transformation, 2-D viewing function, clipping operations,
port clipping, line dipping, Sutherland / Cohens line clipping algo, polygon clipping algo,
projection, visible line and surface identification, Bergier Curves & V spline curves.
CHAPTER 8 VISIBILITY Z BUFFER ALGORITHM
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, co-ordinate 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 thats 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.
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 thats 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.
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 thats 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
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
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 thats 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
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 thats 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 x-coordinate and one for y-co-ordinate 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
LINE
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 , 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)
and current cursor
position (40, 55)
(40,50)
(60,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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
(30,30) (70,30)
INTERNAL OPERATION
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 thats 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 co-ordinates. Generally, the screen coordinates are taken as positive (x, y) plane. Hence the screen is continuously refreshed
by scanning from maximum value of y-coordinate down to y = 0.
Distinguish between Raster & Random Scan
RASTER SCAN DISPLAY
i)
i)
ii)
ii)
iv) They are more suited to geometric iv) They are more suited to line
area drawing applications e.g.
drawing application e.g. CROs
monitors, Tele vision
, pen plotter.
COLOUR DISPLAYS
There are 2 methods for producing colour displays.
A. Beam Penetration technique
B. Shadow Mask technique
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 thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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
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 thats 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. Now-a-days 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.
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 thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
2
LINE DRAWING ALGORITHM
ALGORITHMS Line drawing algorithm, DTA algorithm, Presentians 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
y
y 2 y1
1
n
x 2 x1
y
x
& n
y1
x
x1
2
2
x
y
2
2
x1
y
y1
Once the intervals are known, the values for rent x & y can be obtained as follows
xi+1 = xi + x
x
&
i 1
i 1
x
y
2
2
x
y
y
x
2
2
y
x
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.
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 thats it! Get yours now!
If | x | | y |, then x = 1
else y = 1
If, x = 1, then
y
x
i1
i1
y
x
2
2
y1
x1
If, y = 1, then
x i1 x i
y i1 y
x
y
2
2
x1
y1
x 2
Length
&
y 2
Length
[This makes either x & y = 1 because length is either absolute value of (x2 x1) or
absolute value of (y2 y1). 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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. x1 = 0, y1 = 0,
x2 = 4, y2 = 6
2. x = |4 0| = 4, y = |6 0| = 6
4 x
x 2 x1
Length
4
, y
6
y 2 y1
6
1
Length
6
Plot
1
2
3
4
5
6
(1, 1)
(1, 2)
(2, 3)
(3, 4)
(3, 5)
(4, 6)
x
0.67
(1.34)
2.01
2.68
3.35
4.02
4.69
6. y = y1 + Sign (y)
=0+1
=1
t
1
2
3
4
5
6
7
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 thats it! Get yours now!
Q. Consider a line from (0, 0) to (6, 6) use the DDA algorithm to rasterize.
1. x1 = 0
y1 = 0
x2 = 6
y2 = 6
2. x = | 6 0 | = 6
y = | 6 0 | = 6
3. length = x = | x2 x1 | = 6
x 2 x1
6
1
Length
6
y 2 y1
6
y
1
Length
6
4 . x
5. x = x1 + Sign (x),
=0+1
=1
y = y1 + Sign (y)
=0+1
=1
i
0
1
2
3
4
5
Plot
1
(1, 1)
(2, 2)
(3, 3)
(4, 4)
(5, 5)
x
1
2
3
4
5
6
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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
(6, 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
ALGORITHM
STEP 1. Read the line end points (x1, y1) & (x2, y2) such that they are not equal.
2. x = x2 x1 & /
y = y2 y1
3. Initialize starting point as
x = x1 & y = y1
4. e = 2 * y - x
[Initialize value of decesion variables or error]
5. Initialize counter i = 1
6. Plot (x, y)
7. while (e 0)
{
y=y+1
e = e-2 * x
y
x=x+1
e = e + 2 * y
8. i = i + 1
9. If (i x) 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. x1 = 5
x2 = 13
y1 = 5
y2 = 9
2. x = |x2 x1| = 13 5 = 8
y = |y2 y1| = 9 5 = 4
3. x = 5, y = 5
4. e = 2 * y - x
=2*48
=0
5. 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
i
1
2
3
4
5
6
7
8
Plot
5
(5, 5)
(6, 6)
(7, 6)
(8, 7)
(9, 7)
(10, 8)
(11, 8)
(12, 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. 2. Consider a line from (2, 5) to (10, 10). Apply Bresenhams line drawing algorithm to
plot the line.
1. x1 = 2
x2 = 10
y1 = 5
y2 = 10
2. x = |x2 x1| = |10 2| = 8
y = |y2 y1| = |10 5| = 5
3. x = 2
y=5
4. e = 2 * y - x = 2 x 5 8 = 2
e=2
5. i = 1
i
1
Plot
2
(2, 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
2
3
4
5
6
7
8
(3, 6)
(4, 6)
(5, 7)
(6, 7)
(7, 8)
(8, 9)
(9, 10)
4
5
6
7
8
9
10
6
7
8
8
9
10
10
6
4
2
+8
2
-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 thats it! Get yours now!
The Midpoint Circle Generating algorithm uses 8-way of symmetry of the circle
th
generated. If plots 1/8 part of a circle is from 90 to 45. So the x-coordinate who is in
+ve direction & y-coordinate 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 y-positions
are closer to the circular path of each step. The 2 possible y positions are yi and yi-1 and
at same position xi and xi+1. We have to determine whether the pixel at position (xi+1, yi)
as (xi+1, yi-1) is close to the circle. So for that purpose the decision parameter is used
which uses the circle function.
2
2
2
Parde (x, y) = x + y r
The decision parameter
di = Parde (xi + 1, yi )
2
2
2
= (xi + 1) + (yi ) r 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 & yi-1 is closer to the circle
boundary. The incrementry calculation can be determined to obtain the successive
decision parameter.
2
2
2
di+1 = (xi+1 + 1) + (yi+1 ) r
2
2
2
= (xi+1) + 2xi+1 + 1 + (yi+1) yi+1 + - r
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 thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
x2
y2
Eqnofellip seis
1
rx 2
ry 2
2 2
2 2
ry x + rx y = rx ry
2 2
2 2
2 2
ry x + rx y rx ry = 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.
2 2
2 2
fellipse
0 ( x , y ) insideelli
( x , y ) 0 ( x , y ) anellipseb
0 ( x , y ) outsideell
pseboundar
oundary
ipsebounda
y
ry
ry 2 x 2 rx 2 ry 2
dy
d
( y 2 ) ry 2
(x
rx 2
dx
dx
dy
ry 2 . 2 x 0
rx 2 . 2 y
dx
dy
2 x . ry 2
2 y . rx 2
dx
2 x . ry 2
dy
2
2 yrx 2
dx
y
d
dx
( rx
ry
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 thats it! Get yours now!
dy
1
dx
2 x.ry 2
1
2 y.rx 2
Slope
x 2 .ry 2 2 y.rx 2
2
Region 1
The decision parameter at midpoint is
1
P k = fellipse (xR + 1, yR )
2
2
2
2
2 2
= ry (xR+1) + rx (yK-1/2) rx ry 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 yk-1
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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
1
k+1
1
k+1
From Eqn 3
1
k+1
If P k < 0, yk+1 = yk
1
1
2
2
P k+1 = P k +2ry (xR+1) + ry
1
& If P k 0, 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 (yR-1)
In region 1, the value of decesion parameter is obtained by evaluating the ellipse function
at the start position (0, ry)
1
0
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, 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
2
P k = fellipse (xR + , 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
P k = ry (xk + ) + rx (yk 1) rx ry
2
If P k > 0, the midpoint is outside the ellipse boundary and we select the pixel at position
2
xR+1. If P k < 0 then at the next sampling position
i.e.P k 1 ry x R 1 rx 2 ( y k 1 1) 2 rx 2 ry 2
2
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
P 2 k 1 P 2 k rx 2 ( y k 1) 2 ry 2 ( xk 1)
P
1
1
2rx 2rx ( yk 1) rx ry xk 1 y k
2
2
P 2 0 fellipse x , y0 1
2
ry x0 rx 2 ( y0 1) rx 2 ry
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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
A polyline is a chain of connected line segments. It is specified by giving the vertices P0,
P1, P2, & 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
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 thats 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.
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
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 thats 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
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 pixel-position 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 4-connected method, 4-diagonal
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.
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 thats 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 inside-outside 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
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 thats 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 case-1 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
Case-2 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 end-point 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 thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
P 1 2 y ( x 1 1 ) 2 xy
P 1 2 yx
2 y 2 xy
(2 y1 2
1
2 xy
y
x1 1) x
x
2 yx 1 x
P1 2 y x
Thus, we can summarize above calculations as,
P1 = 2y - x
P1+1 = P1 + 2y
if P1 < 0
P1+1 = P1 + 2(y - x)
if P1 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,
P1 = 2x - y
P1+1 = P1 + 2x
if P1 < 0
P1+1 = P1 + 2 (x - 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.
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 x and y as
x abs (x2 x1)
y abs (y2 y1)
3) Initialize the value of (x, y) as (x1, 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
Ans
x abs (12 20) 8, y abs (15 20) 5
Since x1 < x2 i.e. 20 < 12 is false, xinc -1
Since y1 < y2 i.e. 20 < 15 is false, yinc -1
Since x < y is true, then part of step 6 of the algorithm will come in picture. The
calculations can be done as shown below.
xi
yi Pi
Pi+1
20
19
18
17
20 2
19 -4
19 6
18 0
-4
6
0
-6
xi
yi Pi
Pi+1
16
15
14
13
17 -6
17 4
16 -2
16 8
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
20
pixel
yi+1
17
16
16
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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
y =r x
The circle drawing is started from a point (0, r) assuming (0, 0) as center of the circle.
From the diagram-2, we can write,
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,
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, Pi = d1 d2
2
-2
P1 = 2(x1 + 1) + y1 + (y1 1) 2r
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 thats it! Get yours now!
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 ---- 6
The above process can be summarized in steps as follows
Algorithm
1) Read the radius r and center coordinates as (xc, yc).
2) Select first point for display, (x1, y1) = (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
yy1
7) Increment x in unit steps as, x x + 1
Let us assume that (xi, yi) is drawn. The next point to be drawn is to be determined. It will
be either (xi+1, yi) or (xi+1, yi-1). If the midpoint is inside the circle, then (xi+1, yi) is closer
to circle path. If the midpoint is outside the circle, then (xi+1, yi-1) is closer to the circle
path. The decision parameter Pi is calculated as follows,
Pi = fcircle (xi + 1, yi )
2
2
2
Pi = (xi + 1) + (yi ) r
--- 1
The successive decision parameter Pi+1 is obtained as follows,
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
--- 2
The equation 2 1 gives,
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 thats 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,
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
--- 5
From equations 4 and 5 we can say that, we are in position to calculate Pi+1, if we know
Pi. However, we must know Pi. Let us substitute i = 1 in eqn 1 and hence,
2
P1 = (x1 + 1) + (y1 ) r
2
2
P1 = (0 + 1)2 + (r ) r
(x1, y1) = (0, r)
2
2
P1 = 1 + r r + - r
P1 = 5/4 r
--- 6
The above process can be summarized in steps as,
Algorithm
1) Read the radius as r and center coordinates as (xc, yc)
2) Select first point for display as (x1, y1) = (0, r).
3) Calculate the first parameter as P
P 5/4 r
1r
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
yy1
end
7) Increment x in unit steps as x x +1
Display Routine
i) putpixel (xc+x, yc+y)
iii) putpixel (xcx, yc+y)
v) putpixel (xc+y, yc+x)
vii) putpixel (xc-y, yc-x)
Display Routine
i) putpixel (xc+x, yc+y)
iii) putpixel (xcx, yc+y)
v) putpixel (xc+y, yc+x)
vii) putpixel (xc-y, yc+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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
Problem Using Bresenhams 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
xi
yi Pi
Pi+1
xi+1
yi+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
th
is calculated. In this algorithm also, the points are calculated only for 1/8 of circle. The
remaining 7/8 of the circle is achieved using symmetry. This process is same as that of in
Bresenhams algorithm. In midpoint circle algorithm, a circle function is calculated as,
2
2
2
Fcircle (x, y) = x + y r
From the above equation, we can obtain following points,
< 0 if (x, y) lies inside the circle
fcircle (x, y)
= 0 if (x, y) lies on circle boundary
> 0 if (x, y) lies outside the circle
[DIAGRAM]
Ellipse Drawing Algorithm (Midpoint)
st
The midpoint ellipse drawing algorithm is applied throughout the 1 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.
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 thats it! Get yours now!
x2
y2
1
rx 2
ry 2
2
r y x 2 rx y 2 rx r y
r y x 2 rx
rx r y
0
2
f ellipse ( x , y ) r y x 2 r x y 2 r x r y
2 x . ry
dy
/ dx
2 y .r
dy
dx
2 x .r
2
2 yr
2
y
2
dy
dx
xr
yr
2
y
x 2
AT the junction of two regions, the slope becomes 1. In the first region, xi+1 = xi + 1.
The decision parameter is calculated as
P1i = fellipse (xi + 1, yi )
2
2
2
2
2 2
P1i = ry (xi + 1) + rx (yi ) rx ry
--- 1
The successive decision parameter P1i+1 can be calculated 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
--- 2
--- 8
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 thats it! Get yours now!
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) --- 10
If P2i is positive or zero, then midpoint is outside the ellipse or on the ellipse. xi+1 = xi
By putting this condition in eqn 9 we get,
2
P2i+1 = P2i + rx (-2yi + 3)
--- 11
The P2i will be calculated from the last point of region-1.
2
2
2
2
2 2
P2i = ry (x2 + ) + rx (y2 1) rx ry
--- 12
Algorithm
The overall process can be summarized in steps as follows,
1) Read the coordinates (xc, yc) and also read rx and ry.
2) Calculate the initial value of parameter in region 1.
2
2
2
Pi ry rx ry + (1/4) rx
3) Select the first point for display as (0, ry) i.e. x = 0, y = ry
4) Calculate slope as
2
2
- (ry x / rx y)
5) Repeat steps 6, 7, 8, 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)
yy1
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, 13, 14 while (y > = 0)
12) Call display routine
13) If P2 < 0
Then
Begin
2
2
P2 P2 + ry (2x+2) + rx (3-2y)
x x+1
end
2
Else
P2 P2 + rx (3-2y)
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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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 figures boundary is
encountered. This method is called as Boundary fill algorithm.
A boundary-fill 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 4-connected areas.
The boundary-fill algorithm can also be implemented using 8-connected areas. In this
case, alongwith four neighbouring pixels, four diagonal pixels are also tested.
[DIAGRAM]
4-connected areas
8-connected 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 boundary-fill (int x, int y, int fc, int bc)
{ int pc;
pc = getcolor (x, y);
if ( (pc ! = bc)& & (pc ! = fc) )
{
putpixel (x, y, fc);
boundary-fill (x+1, y, fc, bc);
boundary-fill (x-1, y, fc, bc);
boundary-fill (x, y+1, fc, bc);
boundary-fill (x, y-1, fc, bc);
Flood-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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
Both the algorithms are recursive and these algorithms works only for small areas.
These algorithms can also be made non-recursive, 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 sans-serif. The serif type has small lines called as accents at the
ends of main character strokes. The sans-serif font does not have accents.
The text in serif font can be like ABCDEF.
The text in sans-serif 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
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 thats 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 -
p (u )
Pk
. Bk
, n (u )
k 0
where,
Bk , n ( u ) c ( n , k ).u k (1 u ) n k andc n , k
n!
k ! ( n k )!
y(u ) yk .Bk , n (u )
k 0
n
z (u ) zk .Bk , 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
The polynomials Bk,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, B0,3(u), B1,3(u), B2,3(u)
and B3,3(u). All these functions can be calculated using Bk,n(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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
Since
, P (u )
Pk .B
k ,n
(u )
k 0
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 B-Spline Curves
The spline is a flexible strip, used to produce the smooth curve, through set of given
points. In B-spline curve, n+1 control points are given. These points are denoted as Pk
n
P (u )
Pk . N k , t ( u )
k 0
(xk, yk, zk), where k varies from 0 to n. the B-spline curve can then be defined as,
Where, Nk,t(u) can be defined as polynomials of degree t-1. A polynomial form of the
blending function can be defined recursively, over various sub-intervals 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,
Nk,t = 1
if uk u < uk+1
=0
otherwise
(u )
u uk
N
u k t 1 u k
k ,t 1
(u )
ukt u
N
u k t u k 1
k 1,t 1
(u )
k ,t
0 ifj t
j t 1 ift j n
n t 2 ifj n
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 thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
heavy-ascillations
variasion-diminishing 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.
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 thats 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.
1.1
1.2
1.3
2.
2.1
2.2
2.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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
x
y
x
y
1
1
x
y
x1
x t x
i .e . 1
y t y
y
Ex. Translate a polygon with co-ordinates A (2, 5), B (7, 10) and C (10, 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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.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.
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 thats it! Get yours now!
Using trignometary,
1
x = r cos( + ) = r cos cos - r sin sin
1
y = r sin ( + ) = r cos sin + r sin cos 1
The original co-ordinates are
x = r cos
y = r sin 2
Substituting 2 in 1, we get,
1
x = x cos - y sin
1
y = y sin + y cos 3
The above equations can be represented in the matrix form
[ x
y
1
[ xy
sin
cos
]
sin
cos
P .R
cos sin
sin 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
cos( ) sin( )
R
sin( ) cos( )
cos sin
R
sin
cos
Ex. A point (4, 3) is rotated conter clockwise by an angle of 45. Find the rotation matrix
and the resultant point.
Sol.
sin
cos
1 / 2 1 / 2
1 / 2 1 / 2
1 / 2 1 2
P [ 43 ]
1 / 2 1 2
1
[4 /
2 3/
[1 /
27 /
24/
2 3 2]
1.3 SCALING
A scaling transformation changes the size of an object. This operation can be carried out
for polygons by multiplying the co-ordinate values (x, y) of each vertex by scaling factors
Sx and Sy to produce the transformed co-ordinates (x1, y1)
1
x = x.Sx
1
& y = y. Sy 1
Scaling factor Sx scales object in x direction and scaling factor Sy scales object in 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
S x 0
[ x 1 y 1 ] [ xy ]
0 S y
[ x .S x y .S y ]
P .S
Values assigned to Sx & Sy 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 co-ordinates A (2, 5), B (7, 10), C (10, 2) by 2 units in x direction
& 2 units in y direction.
Soln. Here Sx = 2 & Sy = 2
Transformation matrix is given as
S
20
02
Theobjectm
B
[ 710
[ 102
]
1
[ 25
atrixisA
]
[ 25
[ 102
20
]
02
[ 710
20
02
20
02
[ 410
[ 204
[ 1420
]
]
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 thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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
1
P = P . M1 + M2 1
ForTransla
i .e . M
M
ForRotatio
M
i .e . M
nP
Rotational
10
P
01
trix
tx
ty
nMatrix
cos sin
0
P
sin cos
0
Matrix
ForScaling
IdentityMa
Translatio
tionP
S x 0
0
P
0
0 S y
rix
ScalingMat
P
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 thats it! Get yours now!
Xw
W
&
Yw
W
100
T 010
txt y1
wehave
100
[ x y 1 ] [ xy 1 ] 010
txt y1
[ x txy
ty 1 ]
cos sin 0
sin cos 0
RotationR
001
cos sin 0
1
1
[ x y 1 ] [ xy 1 ] sin cos 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
[
[
x
x
. S
00
001
1
1
y
]
. S
xy
00
001
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.
x1
10 t x x
1
i . e . y 01 t y y
1
001 1
Ex 1. Consider a square ABCD with co-ordinate 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)
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 thats it! Get yours now!
. S .T
B
B
A .[ T
. 51
. 51
C .[ T
. S .T
[ 2 . 52
[ 1 . 52
D .[ T
. 51
. S .T
. 51
100
010
2
221
100
. 010
221
0 . 500
] 00 . 50
111
[ 111
[ 2 . 51
0 . 500
00 . 50 T
001
0 . 500
. 00 . 50
21 001
S .T
B .[ T
100
010
2
100
010
221
[ 1 . 51
21
0 . 500
00 . 50
1 11
0 . 500
00 . 50
111
100
010
[ 311
0 . 500
] 00 . 50
111
[ 331
0 . 500
] 00 . 50
111
[ 131
0 . 500
] 00 . 50
111
. S .T
( 1 . 5 ,1 . 5 ) C
( 2 .5 ,2 .5 ) D
( 2 .5 ,2 .5 )
(1 . 5 , 2 . 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
)
T
)
T
100
010
021
40
ty
. 5
tx
100
010
ty
. 51
Heretx
100
010
10
Herety
100
010
301
Heretx
Heretx
100
010
txty
. 661
ty
. 66
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 thats it! Get yours now!
cos
sin
001
45
1 /
1
001
2 1
1 /
1
111
[ 101
[1
A
1 /
1
001
2 1
2 1
A .[
&
2 1
/
(1
1 , B
1
2
1 ,
1
2
. R
/
2 1
2
/
0
2
2 1
/
2 1
2 1
2 1
/
/
A .[ T
11
2 1
0
2
1 /
. 1
001
2 1
100
0 010
111
1 )
1 /
] 1
2
/
1 ,
100
010
111
2 1
(1 ,
. R
2
/
2 1
/
2 1
.T
2 1
/
1 /
] 1
111
[ 101
.T
1 /
0
A
/
2 1
b ) T
450
nmatrixis
100
010
111
450
cos
Translatio
sin
45
2 1 ]
2
, 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
B .[ T . R ]
1 /
21 /
2 0
[ 011 ] 1 /
21 /
2 0
0
2
1
[ 1 /
B
C
( 1 /
2 1]
2 ,3 /
2 )
C .[ T . R .]
1 /
2 1 /
2 0
] 1 /
2 1 /
2 0
0
2
1
[ 111
[ 02
C
2 3 /
2 1]
(0 ,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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
T 1 010
xp yp 1
2. The rotation matrix for counter clockwise rotation of point below the origin is
cos sin 0
R sin cos 0
001
3. 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
100
T 2 010
xpyp 1
Therefore, the overall transformation matrix for a counter clockwise rotation by an angle
& about the point (xp, yp) is given as
100
cos sin 0 100
sin cos 0 010
T1.R.T2 010
xp yp1 001
xpyp1
cos sin 0
sin cos 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
Soln. Here xp = 1, yp = 1 = 45
T1
100
100
, T 010
010
2
1 11
111
1 /
21 /
2 0
1 /
2
1
/
2
0
001
We
have
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 thats it! Get yours now!
T 1 . R .T
cos sin 0
sin cos 0
xp cos yp
Substituti
T 1 . R .T
ngvalueswe
sin
get
xp
xp
sin
yp cos
yp 1
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 .[ T 1 . R . T 2 ]
1 /
2 1 /
2 0
] 1 /
21 /
2 0
2 11
[ 231
3
2
2
3
1 ,1
5
2
5
2
2 11
2 11
1,
1
2
C [ T 1 . R .T 2 ]
1
1 /
2 1 /
2 0
21 /
2 0
1 /
[ 431 ]
21 /
2 0
1 /
1
2 11
3
4
3
4
2
2
2
2
2 11
1 /
2 1 /
2 0
] 1 /
21 /
2 0
2 11
1
B [ T 1 . R .T
[ 551
3
2
1
2
11
1
2
1,
5
2
5
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 thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
COMMON REFLECTIONS
4.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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
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 co-ordinate, 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
1Shy 0
Y _ sh 010
001
X1 X &
y1 y Ysh.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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
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 yref = -1
b) Shear parameter of 0.5 relative to line xref = -1.
Xshearwith
yshearwith
yreference
xreference
line
line
100
Sh x 10
sh x . y
1 Sh y 0
010
0 Sh
ref
ref
01
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 thats it! Get yours now!
100
Sh 10
Sh
001
101
111
011
A 1 [ 0
B
[ 1 . 500
[ 211
.Y
100
0 . 510
0 . 501
501
111
01
ref
]
]
( 0 .5 ,0 ) C
(1 . 5 , 0 ) D
( 2 ,1 )
( 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
B
C
001
101
111
011
00
111
121
01
1
. 51
A
B
1 Shy
010
0
. 50
10
0 . 510
0 . 50
. 51
0
Sh
ref
. 51
( 0 , 0 . 5 )
( 1 ,1 )
(1 , 2 )
( 0 ,1 . 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
0
1 Shy
Shx
10
001
S x 00
sin
cos
sin
0
0
cos
S
R
001
001
S x Cos
S x Sin
0
S . R S y Sin
S y Cos
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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
1
and
cos
1
cos
Sx
S
Sh
Sh
1
cos
1
cos
Sin
tan
Sin
tan
0
1 tan
tan
10
001
S x Cos
S
S
AngleofRot
xscale
yscale
Cos
ation
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 thats it! Get yours now!
6
2-D VIEWING
Viewing pipeline, viewing co-ordinates reference frame, window to view part co-ordinate
transformation, 2-D 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 CO-ORDINATE
SYSTEM.
However when the picture is displayed on the display device it is measured in
physical device co-ordinate system (PDCS) corresponding to the display device.
Therefore displaying an image of a picture involves mapping the co-ordinates 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 co-ordinates is achieved with
the use of co-ordinate transformation known as viewing transformation i.e. the
viewing transformation maps picture co-ordinate 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.
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 thats it! Get yours now!
Xv Xv min
Xv max
Xv min
Xw Xw min
Xw max
Wx min
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 thats it! Get yours now!
3) The object and the window are scaled until the window has the dimensions of the
viewport.
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 thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
100
T 010
X w min Y w min 1
S x 00
S 0 S y 0
001
Sx
X v max X v min
X w max X w min
Sy
Y v max Y v min
Y w max Y w min
100
T1 010
X v min Y v min 1
100
S x 00 100
0 S 0 010
W T .S .T1 010
y
0 S y 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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
Xwmin X Xwmax and
Ywmin Y Ywmax
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.
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 thats it! Get yours now!
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.
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 thats it! Get yours now!
Line
P1P2
P3P4
P5P6
P7P8
P9P10
Logical AND
Result
Comp. Visible
Comp. 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. 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)
c) We know that for P1P1 one endpoint P1 is outside the window &
1
thus the line segment P1P1 is discarded. The line is now
1
reduced to the section from P1 to P2.
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 thats 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
P1 (x1, y1) & P2 (x2, y2) is
Y = m(x x1) + y1 or y = m(x x2 ) + y2
wherem
y
x
2
2
y1
slopeoflin
x1
1.
2.
3.
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 thats 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 a-b, c-d, d-e, f-g, g-h, I-j are added to polygon description to make it closed.
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 thats 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.
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 thats 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.
st
4. If the 1 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.
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 thats 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.
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 thats 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. Lagranges Interpolation technique
2. Bezier
generation technique
3. B-Spline 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
co-ordinate values along the known curve and joining them by small straight line
segments as shown in the figure above.
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 thats it! Get yours now!
We have to construct the function as sum of terms, one term for each sample point.
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 )
Using the Blending function, the expression for the curve passing through sample
points can be realised as:
x = x1B1(u) + x2B2(u) + x3B3(u) + - - - - - y = y1B1(u) + y2B2(u) + y3B3(u) + - - - - - z = z1B1(u) + z2B2(u) + z3B3(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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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)
2)
3)
4)
The lines joining the 4 connecting points (A, B, C, D) are determined (AB, BC, CD)
Then their midpoints (AB, BC, CD) are determined & connected by line segments.
Then their midpoints (ABC, BCD) are determined.
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.
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 thats 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 co-ordinate position along a
B spline curve in a Blending function formulation as
n
P u Pk Bk , d (u ) 2 d n 1
k 0
Where
Pk i/p set of n+1 control points.
Bk, d B-Spline Blending function which is a polynomial of degree d 1
D can be any integer value between 2 & n + 1
Blending functions for B-Spline curves are defined by Can De Boor recursion
formula.
Bk , d (u )
u uk
u d u
Bk , d 1(u ) k
Bk 1 , d 1(u )
uk d 1 uk
u k d u k 1
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.
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 thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
7
INTRODUCTION TO 3D
3-D Coordinate System
The figure shows three dimensional cartesian
coordinate system. This is called as right-handed
system because right-hand thumb points in
positive z direction. Most Graphics packages
utilises right-handed system. Another possible
arrangement is left handed system.
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 x-y plane. The surface of
constant is a vertical plane which
contains z axis. Then x, y and z are
given as,
x = cos , y = rsin , 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
Spherical
The surface of constant r is a sphere. The
surface of constant is a vertical plane
which contains z axis. The surface with
constant is a cone which is having apex
at origin.
From the diagram,
x = rcossin y = rsinsin z = rcos
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.
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 thats 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.
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 thats 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 dia-a, it is difficult to decide whether the object is like dia-b or dia-c.
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
non-visible lines as dashed lines or simply remove non-visible 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 Ray-Tracing, 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 3-D viewing of the 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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
observers 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 Xw-Yw-Zw 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 Xv-Yv-Zv.
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.
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 thats 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.
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 thats 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.
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 thats it! Get yours now!
1000
0100
[ x p y p z p 1] [ xyz1]
0000
00 z v p 1
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,
xp = x + Lcos
yp = y + Lsin
and tan
Z L
1
L Z tan
1
1
ZL1 whereL1
tan
tan
xp x zL1 cos
L Z.
yp y zL1 sin
Any parallel projection can be defined as,
1000
0100
[ X p Y p Z p 1] [ xyz1]
L1 cos L1 sin 00
00 Z v p 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
1
0
tan
x p x, y p y, z p z conditionsfororthographic
L1
(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 Zprp along Zv axis and view
plane is placed at zvp.
The coordinate positions can be defined in
parametric equations along projection line.
1
x = x xu
1
y = y yu
1
z = z (z-prp) u
The parameter u can take value from 0 to 1. When u = 0, then (x , y1, z ) = (x, y, z)
1
1
1
whereas when u = 1 then (x , y , z ) = (0, 0, zprp). The projection reference point lies on zv
axis. On the view plane, u will be 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
z vp Z
z prp Z
1
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.
z prp z
Similarly,
z prp z vp
y p y.
z prp z
and
z p z vp
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 3-D is achieved by extending the ideas of twodimensional clipping.
Instead of clipping against 2-D 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.
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 thats it! Get yours now!
The objects in the view volume in world coordinates are transformed to unit cube (volume
viewport).
The factors Dx, Dy and Dz are the ratios of the viewport and regular window view volume.
Dx
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
Dz
z v max z v min
z w max z w min
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 thats 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,
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, 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.
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.
If value of u is between 0 and 1 then there exists intersection and intersecting point will
be given as follows.
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 thats it! Get yours now!
z
z1
x x1 ( x 2 x1 ) v min
z 2 z1
z
z1
y y1 ( y 2 y1 ) v min
z 2 z1
z z v min .
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 thats 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 hidden-surface elimination methods.
Visible surface detection algorithms are broadly classified according to the way of
working. The two different approaches are object-space methods or image-space
methods.
An object-space method compares the objects and parts of the object with each other
within the scene definition, to determine visible surfaces.
In an image-space method, visibility is decided pixel by pixel at each position on the
projection plane. Most of the algorithms are of image-space 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,
Ax + By + Cz + 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, (x1, y1, z1), (x2, y2, z2) and (x3, y3, z3) on the plane. These three
points will form simultaneous equations as,
Ax1 + By1 + Cz1 + D = 0
Ax2 + By2 + Cz2 + D = 0
Ax3 + By3 + Cz3 + D = 0
In the above equations, A, B, C and D are unknown. Let us rearrange the equations 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
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
x3 y 3 z 3
x 11z1
x3 y 3 z 3
x1 y11
x1 y1 z1
A 1 y 2 z 2 B x 2 1z 2 C x 2 y 2 1 D x 2 y 2 z 2
1y3 z3
x3 1z 3
x3 y 3 1
x3 y 3 z 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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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 Zv 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 C1 of N1 will be negative whereas component C2 of N2
will be positive and hence surface with normal N1 is a back-face and hence it is to be
removed while displaying. The surface with normal N2 is considered to be front-face and
hence it is to be displayed.
Depth-Buffer (z-buffer) method
The depth buffer method is commonly used image-space 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 z-buffer method. This is because, usually,
he depth is measured from view plane along z-axis. 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)
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 thats 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 depth-buffer 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) = Ibackground
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) Isurf (x, y)
Where, Ibackground is background intensity.
Isurf (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.
Ax By D
C
1
If the depth of position (x, y) has been determined to be z, then the depth z of the next
position along the same scan line i.e. (x+1, y) is obtained as,
A( x 1) By D Ax By D A
C
C
C
A
z1 z
C
z1
Similarly, depth values for succeeding scan lines can be obtained as follows,
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 thats it! Get yours now!
Ax B( y 1) D
C
Ax By D B
z 11
C
C
B
z 11 z
C
z 11
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 thats 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 computergenerated 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., show-case 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
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 thats it! Get yours now!
In general, an animation sequence is designed with the help of the following steps
Storyboard layout
Object definition
Key-frame specification
Generation of in-between frames
Definition of frame :For frame-by-frame 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 real-time 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.
In-between frames are file intermediate frames between the key frames. The number
of in-between frames needed is determined by the media to be used to display the
animation. Film requires 24-frames 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 real-time 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.
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 thats 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.
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.
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 thats 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, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats 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.
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 thats 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. Back-face removal algorithm, Zbuffer algorithm, warnockls algorithm etc.
Depth Buffer algorithm: One of the simplest & commonly used image space approach to eliminate hidden
surface is the Z-buffer 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 z-values & hence the name zbuffer algorithm.
The implementation requires another buffer memory called z-buffer along with the
frame buffer memory required for raster display devices.
The z-buffer 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 depth-buffer 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.
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 thats 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 x1, int y1, int x2, int y2);
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
Rectangles upper left corner
right, bottom
Rectangles lower right corner
Eg :Bar (200, 200, 300, 300);
5. rectangle ( );
Draw a rectangle in current line style, thickness & drawing color.
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. Compatible across
nearly all Windows platforms, simply open the document you want to convert, click print, select the
Broadgun pdfMachine printer and thats it! Get yours now!
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);
8.
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);
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.
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 thats 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);
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 thats 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);
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 thats it! Get yours now!