SlideShare a Scribd company logo
Unit 2: Raster Scan Graphics
Mr. C. P. Divate
Line generation Algorithm in Computer Graphics
• In any 2-Dimensional plane if
we connect two points (x1, y1)
and (x2, y2), we get a line
segment.
• But in the case of computer
graphics we can not directly join
any two coordinate points, for
that we should calculate
intermediate point’s coordinate
and put a pixel for each
intermediate point, of the
desired color with help of
functions like putpixel(x, y, K)
in C, where (x,y) is our co-
ordinate and K denotes some
color.
Examples:
Input: For line segment between (3, 2) and (6,
5) :
we need (3, 2),(4, 2) (4, 3) ….. (5, 5) as our
intermediate points.
Line generation Two-point form equation of
line Computer Graphics
• Let P(x,y) be the general point
on the line L which passes
through the
points A(x1,y1) and B(x2,y2)
Basic properties of line drawing in Computer
Graphics
The primary design criteria are as follows.
 Straight lines appear as straight lines.
 Straight lines start and end accurately.
 Displayed lines should have constant brightness along their
length, independent of the line length and orientation.
 Lines should be drawn rapidly.
Basic mathematics to draw line drawing in
Computer Graphics
Method-1 : Direct Method :
In this algorithm, we have two endpoints. We find the slope of the line by using
both the points, and we put the slope in the line equation y = mx + b.
Basic properties of line drawing ALGORITHMS
in Computer Graphics
An algorithm should be precise: Each step of the algorithm
must be adequately defined.
Finiteness: An algorithm must contain finiteness. It means the
algorithm stops after the execution of all steps.
Easy to understand: An algorithm must help learners to
understand the solution in a more natural way.
Correctness: An algorithm must be in the correct manner.
Effectiveness: Thesteps of an algorithm must be valid and
efficient.
Uniqueness: All steps of an algorithm should be clearly and
uniquely defined, and the result should be based on the given
input.
Input: A good algorithm must accept at least one or more input.
Output: An algorithm must generate at least one output.
DDA Line Generation Two-point form equation
of line Computer Graphics
DDA Line generation Two-point form equation
of line Computer Graphics
DDA Algorithm:
Step 1: Start Algorithm
Step 2: Declare x1,y1,x2,y2,dx,dy,x,y as
integer variables.
Step 3: Enter value of x1,y1,x2,y2.
Step 4: if ABS (x2-x1) > ABS (y2-y1) Then
step = abs (x2-x1)
else
step = abs (y2-y1)
Step 5: dx=(x2-x1)/step
dy=(y2-y1)/step
assign x = x1 + 0.5
assign y = y1 + 0.5
i=1
Step 6: Set pixel (x, y)
Step 7: while( i <= step )
x = x + dx
y = y + dy
i=i+1
Set pixels (Round (x), Round (y))
Step 8: End Algorithm
Example draw line from (0,0) to (4,6)
dx=0.7
dy=1 step=6
DDA Line generation Two-point form equation
of line Computer Graphics
DDA Algorithm:
Step 1: Start Algorithm
Step 2: Declare x1,y1,x2,y2,dx,dy,x,y as
integer variables.
Step 3: Enter value of x1,y1,x2,y2.
Step 4: if ABS (x2-x1) > ABS (y2-y1) Then
step = abs (x2-x1)
else
step = abs (y2-y1)
Step 5: dx=(x2-x1)/step
dy=(y2-y1)/step
assign x = x1 + 0.5
assign y = y1 + 0.5
i=1
Step 6: Set pixel (x, y)
Step 7: while( i <= step )
x = x + dx
y = y + dy
i=i+1
Set pixels (Round (x), Round (y))
Step 8: End Algorithm
Example draw line from p1(2,3) to p2(6,6)
i ( x , y ) x y
DDA Line generation Two-point form equation
of line Computer Graphics
Advantages :
i. It is simple and easy to implement algorithm.
ii. It avoid using multiple operations which have high time
complexities.
iii. It is faster than the direct use of the line equation because it
does not use any floating point multiplication and it calculates
points on the line.
Disadvantages :
i. It deals with the rounding off operation and floating point
arithmetic so it has high time complexity.
ii. As it is orientation dependent, so it has poor endpoint
accuracy.
iii. Due to the limited precision in the floating point representation
it produces cumulative error.
Basis of the algorithm:
A
B
Start position
From start position decide A or B next
• A more efficient approach
• It is suited for implementation on CRT device.
• The algorithm seeks to select optimum(accurate) raster location to draw
straight line.
• For this algorithm increments either x or y by one depending on slope of line.
Basis of the algorithm:
A
B
Start position
From start position decide A or B next
• The increment in other variable ,either 0 or 1is determined by
actual line and distance between the actual line and nearest grid
location.
• This distance is called error e
For a given value of x
• If the slope of line is greater than or equal to ½ then line intercept at x=1
is closer to y=1.
• If the slope of line is less than ½ then line intercept at x=1 is closer to y=0.
• Reason is,
one pixel lies at distance ti above the line, and one pixel lies at distance si
below theline
Trueline
ti
si
• The increment in other variable ,either 0 or 1is determined by actual line and
distance between the actual line and nearest grid location.
• This distance is called error e
1
2
≤
Δ𝑦
Δ𝑥
≤ 1 𝑒 ≥ 0 𝑝𝑙𝑜𝑡 1,1
0 ≤
Δ𝑦
Δ𝑥
<
1
2
𝑒 < 0 𝑝𝑙𝑜𝑡 1,0
1
2
Δ𝑦
Δ𝑥
1
0
For a given value of x
• If the slope of line is greater than or equal to ½ then line intercept at x=1
is closer to y=1.
• If the slope of line is less than ½ then line intercept at x=1 is closer to y=0.
• Reason is,
one pixel lies at distance ti above the line, and one pixel lies at distance si
below theline
Trueline
ti
si
• The increment in other variable ,either 0 or 1is determined by actual line and
distance between the actual line and nearest grid location.
• This distance is called error e
1
2
≤
Δ𝑦
Δ𝑥
≤ 1 𝑒 ≥ 0 𝑝𝑙𝑜𝑡 1,1
0 ≤
Δ𝑦
Δ𝑥
<
1
2
𝑒 < 0 𝑝𝑙𝑜𝑡 1,0
1
2
Δ𝑦
Δ𝑥
1
0
For a given value of x
• If the slope of line is greater than or equal to ½ then line intercept at x=1
is closer to y=1.
• If the slope of line is less than ½ then line intercept at x=1 is closer to y=0.
• Reason is,
one pixel lies at distance ti above the line, and one pixel lies at distance si
below theline
Trueline
ti
si
• The increment in other variable ,either 0 or 1is determined by actual line and
distance between the actual line and nearest grid location.
• This distance is called error e
1
2
≤
Δ𝑦
Δ𝑥
≤ 1 𝑒 ≥ 0 𝑝𝑙𝑜𝑡 1,1
0 ≤
Δ𝑦
Δ𝑥
<
1
2
𝑒 < 0 𝑝𝑙𝑜𝑡 1,0
1
2
Δ𝑦
Δ𝑥
1
0
Bresenham Line Algorithm
The algorithm start with error term with following error term equation,
e = m - ½
Subsequent increments in e will be e = e + m
LineBres(int x1, int y1, int x2, int y2) // line for |m| < 1
{
Step 1: Start Algorithm
Step 2: Declare x1, y1, x2, y2, dx, dy, x, y as integer variables.
Step 3: dx = x2 – x1, dy = y2 – y1,
x=x1, y=y1
m=dy /dx
e = m – ½
Step 4:
for i= 0 to dx
{
setpixel (x,y)
while(e>0)
{
y = y+1
e=e-1
}
x=x+1
e=e+m
next I
Setp 5: Finish
Floating point Bresenham’s Line Algorithm:
e = m – ½
e =
𝑑𝑦
𝑑𝑥
-
1
2
( where m=
𝑑𝑦
𝑑𝑥
)
e =
2 𝑑𝑦 − 𝑑𝑥
2 𝑑𝑥
2dx e = 2 dy - dx - ( I )
Here let, ê = 2dx e - ( II )
Hence,
ê = 2 dy - dx - ( III )
Integer Bresenham’s Line Algorithm:
e = e + m
e = e +
𝑑𝑦
𝑑𝑥
e =
e dx + dy
𝑑𝑥
e dx = e dx + dy
Multiply both side by 2
2e dx = 2e dx + 2 dy – (IV)
Use eqn ( III ) in ( IV )
ê = ê + 2 dy - ( V )
Convert following floating point equations to integer equation to run
algorithm fast,
e = m – ½ e=e+m e=e-1
e=e-1 - ( V )
Multiply both side of ( V ) by 2.dx
2 dx e = 2 dx e - 2dx - ( V )
As, ê = 2dx e - ( II )
Hence, ê = ê - 2dx - ( III )
Integer Bresenham’s Line Algorithm:
Convert following floating point equations to integer equation to run
algorithm fast,
e = m – ½ e=e+m e=e-1
LineBres(int x1, int y1, int x2, int y2) // line for |m| < 1
Step 1: Declare x1, y1, x2, y2, dx, dy, x, y as integer variables.
Step 2: dx = x2 – x1, dy = y2 – y1,
x = x1, y = y1
ê = 2 dy - dx
Step 3: for i= 0 to dx step i = i + 1
{
setpixel (x,y)
while( ê >0)
{
y = y+1
ê = ê - 2dx
}
x=x+1
ê = ê + 2 dy
}
Setp 5: Finish LineBres
Integer Bresenham’s Line Algorithm:
General Bresenham’s Line Algorithm:
Depending on quadrant the increment / decrement in x and y will be as above
General Bresenham’s Line Algorithm:
General Bresenham’s Line Algorithm:
Advantages / disadvantages of Bresenham Line Algorithm:
The advantages of Bresenham Line Drawing Algorithm are-
• It is easy to implement.
• It is fast and incremental.
• It executes fast but less faster than DDA Algorithm.
• The points generated by this algorithm are more accurate than
DDA Algorithm.
• It uses fixed points only.
The disadvantages of Bresenham Line Drawing Algorithm are-
• Though it improves the accuracy of generated points but still the
resulted line is not smooth.
• This algorithm is for the basic line drawing.
• It can not handle diminishing jaggies.
Basic Concepts in Circle Drawing
 Circle is a symmetrical figure.
 The shape of the circle is similar in each quadrant
 It has eight-way symmetry
1) Plot (x,y)
2) Plot (y,x)
3) Plot (-x,-y)
4) Plot (-y,-x)
5) Plot (-x,y)
6) Plot (y, -x)
7) Plot (x,-y)
8) Plot (-y,x)
25
• Polynomial Method
• x2 + y2 = r2
• Trigonometric Method
• x= r cos Ө
• Y = r sin Ө
26
Methods to Represent a Circle
r
r
General Bresenham’s Circle Algorithm:
• Most efficient algorithm to draw circle is Bresenham’s Circle
Algorithm.
• The Bresenham’s circle drawing algorithm considers the eight
way of the symmetry of the circle to generate it.
General Bresenham’s Circle Algorithm:
• At the beginning only one octant of the
circle generation is needed.
• Other parts of circles are drawn by
successive reflections.
1) e.g. if circle has drawn in first octant (0
to 450 ccw)
2) The second octant is obtained by
reflection through the line y=x to yield
first quadrant.
3) The results(pixels) in first quadrant are
reflected through the line x=0 to obtain
the second quadrant pixels.
4) The combined results (pixels) of upper
semicircles are reflected through the
line y = 0 to complete the circle.
Bresenham’s Circle drawing Algorithm:
29
• It plots 1/8th part of the circle i.e. from 90ᵒto 45ᵒ.
• As circle is drawn from 90ᵒ to 45ᵒ, the x moves in positive e
direction and y moves in the negative direction.
Bresenham’s Circle drawing Algorithm
Actual Distance of raster pixel A and B from origin
Bresenham’s Circle drawing Algorithm
X i
Y i
Δ i
Bresenham’s Circle drawing Algorithm
X i
Y i
Δ i
1) If Δ i < 0 then, diagonal point is inside the actual circle, either pixel at (xi +1,
yi) i.e. mH or that at (xi +1 , yi -1) i.e. mD must be chosen. To decide
which own calculate δA = mH - mD
A
---------- ( I )
----- ( II )
A
A
Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 )
Bresenham’s Circle drawing Algorithm
Let us simplify, δA = mH - mD
𝝏𝑨 = | (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊
𝟐 - R 2 | - | ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 - R 2 ) |
𝜕𝐴 = | ( (𝑥𝑖 + 1)2 + 𝒚𝒊 − 𝟏 𝟐 − R 2 ) | - | ( (𝑥𝑖 + 1)2 + 𝒚𝒊 − 𝟏 𝟐 - R 2) |+ (2𝒚𝒊 + 1)
𝜕𝐴 = 2| ( (𝑥𝑖 + 1)2 + 𝒚𝒊 − 𝟏 𝟐 − R 2 ) | + 2𝒚𝒊 + 1
𝜕𝐴 = 𝟐Δ 𝒊 + 2𝒚𝒊 + 1
𝜕𝐴 = | (𝑥𝑖 + 1)2
+ 𝒚𝒊
2
− 2𝒚𝒊 - 1 - R 2 | - | ( (𝑥𝑖 + 1)2
+ 𝑦𝑖 − 1 2
- R 2) |+ (2𝒚𝒊 + 1)
𝜕𝐴 = 𝟐 ( 𝜟 𝒊 + 𝒚𝒊 ) + 1 ---------[ III ]
𝜕𝐴 = | (𝑥𝑖 + 1)2
+ 𝒚𝒊
2
− (2𝒚𝒊 + 1) - R 2 | - | ( (𝑥𝑖 + 1)2
+ 𝑦𝑖 − 1 2
- R 2) |+ (2𝒚𝒊+1)
Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐
+ 𝒚𝒊 − 𝟏 𝟐
− R 2 )
Bresenham’s Circle drawing Algorithm
X i
Y i
Δ i
2) If Δ i > 0 then, diagonal point is outside the actual circle, either pixel at
(xi +1 , yi -1) i.e. mD or that at i.e. (xi yi + 1) mV must be chosen.
To decide which own calculate δB = mD - mV
Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 )
B
B
B
Bresenham’s Circle drawing Algorithm
Let us simplify, δA = mD - mV
𝝏𝑩 = | (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 - R 2 | - | ( x𝒊
2 + 𝒚𝒊 − 𝟏 𝟐 - R 2 ) |
𝜕𝐵 = | (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 | - | ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 - R 2) | − 2𝒙𝒊 − 1
𝜕𝐵 = 2| ( (𝑥𝑖 + 1)2 + 𝒚𝒊 − 𝟏 𝟐 − R 2 ) | - 2𝒙𝒊 - 1
𝜕𝐵 = 𝟐Δ 𝒊 − 2𝒚𝒊 − 1
𝜕𝐵 = | (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 | - | ( (𝑥𝑖 2 + 𝟐 𝒙 + 𝟏 + 𝑦𝑖 − 1 2 - R 2) | − 2x𝒊
− 1
𝜕𝐵 = 𝟐 ( 𝜟 𝒊 − 𝒙𝒊 ) - 1 ---------[ IV ]
𝜕𝐵 = | (𝒙𝒊 + 𝟏)𝟐
+ 𝒚𝒊 − 𝟏 𝟐
− R 2 | - | ( (𝑥𝑖 2 + (𝟐 𝒙 + 𝟏) + 𝑦𝑖 − 1 2
- R 2) | − (2x𝒊+1
Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐
+ 𝒚𝒊 − 𝟏 𝟐
− R 2 )
Bresenham’s Circle drawing Algorithm
X i
Y i
Δ i
3) If Δ i = 0 then, δA = mH – mD Here mD = Δ i = 0, hence δA = mH
which means δA >=0 hence diagonal pixel ((𝒙𝒊 + 𝟏) , 𝒚𝒊 − 𝟏 ) is
selected i.e movement is mD
OR
3) If Δ i = 0 then, δB = mD - mV Here mD = Δ i = 0, hence δB = - mV which
means δB < 0 hence diagonal pixel ((𝒙𝒊 + 𝟏) , 𝒚𝒊 − 𝟏 ) is
selected i.e movement is mD
Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 )
Bresenham’s Circle drawing Algorithm
X i
Y i
Δ i
Bresenham’s Circle drawing Algorithm
Letus make some simplification to obtain values for x, y, 𝜟 𝒊, δA, and
δB to increment or decrement during the loop of algorithm.
1) For Horizontal mH Pixel selection
Bresenham’s Circle drawing Algorithm
Letus make some simplification to obtain values for x, y, 𝜟 𝒊, δA, and
δB to increment or decrement during the loop of algorithm.
2) For Diagonal mD Pixel selection
3) For Diagonal mV Pixel selection
Bresenham’s Circle drawing Algorithm
Letus make some simplification to obtain values for x, y, 𝜟 𝒊, δA, and
δB to increment or decrement during the loop of algorithm.
4) Initial stage or pixel from where Bresenham’s circle algorithm
works
X=0
Y=R
Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 )
Δ 𝒊 = ( 𝟎 + 𝟏)𝟐
+ 𝑹 − 𝟏 𝟐
− R 2 )
Δ 𝒊 = 𝟏 + 𝑹𝟐 − 𝟐𝑹 + 𝟏 − R 2
Δ 𝒊 = 𝟐 − 2R
𝜟 𝒊 = 𝟐(𝟏 − R )
r
(0,R)
Bresenham’s Circle drawing Algorithm Flowchart
Bresenham’s Circle drawing Algorithm
Example on Bresenham’s Circle Algorithm
Bresenham’s Circle drawing Algorithm
Advantages of Bresenham's Circle Drawing Algorithm
1) The Bresenhem’s circle drawing algorithm uses integer arithmetic
which makes the implementation less complex.
2) Due to its integer arithmetic, it is less time-consuming.
3) This algorithm is more accurate than any other circle drawing
algorithm as it avoids the use of round off function.
Disadvantages of Bresenham's Circle Drawing Algorithm
1) This algorithm does not produce smooth results due to its integer
arithmetic as it fails to diminish the zigzags completely.
2) The Bresenhem’s circle drawing algorithm is not accurate in the
case of drawing of complex graphical images.
Polygon
• Polyline is a chain of connected line segments.
It is specified by giving the vertices P0, P1,
P2..and so on.
• The first vertex is called initial point and last is
called terminal point.
P0 P2
46
P1
P3
P4
P5
P6
Polygon
• When initial point and terminal point of any
polyline is same (when polyline is closed)
then it is called polygon.
47
48
• Polygon is a representation of the surface.
• It is primitive which is closed in nature.
• It is formed using a collection of lines.
• It is also called as many-sided figure.
• The lines combined to form polygon are called sides or edges.
The lines are obtained by combining two vertices.
About Polygon
49
Types of Polygon
1. Regular Polygon a regular polygon is a
polygon that is equiangular (all angles are equal
in measure) and equilateral (all sides have the
same length). Regular polygons may be either
convex or star.
50
Types of Polygon
2. Convex polygon is a polygon in which the line
segment joining any two points within the polygon
lies completely inside the polygon
51
3. Concave polygon is a polygon in which the line
segment joining any two points within the polygon
may not lie completely inside the polygon.
52
Types of Polygon
4. Complex polygon is a concave type polygon
with number of edges and the edges are
intersected.
53
Types of Polygon
Polygon Representation
54
The polygon can be represented by listing its n vertices
in an ordered list.
P = {(x1, y1), (x2, y2), ……., (xn, yn)}.
The polygon can be displayed by drawing a line
between (x1, y1), and (x2, y2), then a line between (x2,
y2), and (x3, y3), and so on until the end vertex. In
order to close up the polygon, a line between (xn, yn),
and (x1, y1) must be drawn.
One problem with this representation is that if we
wish to translate the polygon, it is necessary to apply
the translation transformation to each vertex in order
to obtain the translated polygon.
Polygon Filling Algorithm
• An ordered list of vertices forms a polygon.
• Polygon Filling :- The pixels that fall on the border of
the polygon are determined and the pixels that fall
inside are determined in order to color the polygon.
• Polygons are easier to fill since they have linear
boundaries.
• Filling the polygon means highlighting all the pixels
which lie inside the polygon with any color other than
the background color.
Point Inside Test – Even-Odd Method
• Once the polygon is entered, we can draw the outline of
the polygon using drawpoly() command in c/c++.
• To show polygon as a solid object, it is needed to set the
pixel inside the polygon as well as pixels on the
boundary of it.
• Now the question is, to determine whether the point
/pixel is inside or outside of a polygon.
Point Inside Test – Even-Odd Method
• One simple method of doing this is to draw a horizontal
line segment from left to the pixel and count how many
intersections of the line segment with the polygon
boundary occur.
• If there are an odd number of intersections, then the point
is inside, otherwise it is outside.
• This method is called the even-odd method of determining
polygon inside points.
• This inside test or Even-Odd method is used in scan line
method of polygon filling..
Types of Polygon Filling Algorithm
There are two basic approaches used to fill the polygon.
1. Ordered Edge List Algorithm
2. Edge Flag algorithm
3. Edge fill algorithm
4. Fence Fill algorithm
Scanline Polygon Filling Algorithm
• Scanline filling is basically filling up of polygons
using horizontal lines or scanlines.
• The purpose of the SLPF algorithm is to fill (color)
the interior pixels of a polygon for each scanline.
• This algorithm works by intersecting scanline with
polygon edges and fills the polygon between pairs of
intersections.
• These intersection points are then sorted from left to
right, and the corresponding positions between each
intersection pair are set to the specified fill color.
Requirements of all Scanline Fill Algorithm
Find Polygon Bounding box for,
 selection number of scanlines for scanning polygon
 Selection of boundry limit for x co-ordinate for each scanline
1. Ordered Egde List Scanline Algorithm
1) Start with Ymax and move to Ymin or vice versa
2) For each scan line:
a. Find the intersections of the scan line with all edges
of the polygon.
b. Sort the intersections by increasing x coordinate.
c. Fill in all pixels between pairs of intersections
Note
For scan line number 8 the
sorted list of x-coordinates is
(2, 4, 9, 13) Therefore draw
line b/w (2,4) & (9,13)
Y max
Y min
1. Ordered Egde List Scanline Fill Algorithm
Challenges in filling the polygon
 selection number of scanlines for scanning polygon
 Selection of boundry limit for x co-ordinate for each scanline
Scan line 7
Scan line 6
Scan line 3
Scan line 1
One intersection
Three intersections
Three intersections
Number of intersections
7
3
1
SL7: 1
SL6 : 1, 2, 8
SL4 : 1, 4, 6, 8
SL3 : 1, 5, 8
SL2 : 1, 8
SL1 : 1, 2,3,4,5,6,7, 8
Ordered edge list of X
for Scan Line
• It will no support or work if scan line intersects for odd number of times to polygon
• For horizontal line of polygon this algorithm give maximum no of intersections to scanline
hence fail
Scanline Fill Algorithm
Challenges in filling the polygon
 selection number of scanlines for scanning polygon
 Selection of boundry limit for x co-ordinate for each scanline
One intersection
One intersection
Scanline Fill Algorithm
Challenges in filling the polygon
We know that for every scan line we have to calculate x intersection
with every polygon side. We can determine the next x
intersection value as Bounding Box
(x1,y1)
(x2,y2)
Intersecting point
(x, y)
Scan line y
𝑑𝑦
𝑑𝑥
=
(𝑦2 − 𝑦1)
(𝑥2 − 𝑥1)
=
(𝑦 − 𝑦1)
(𝑥 − 𝑥1)
𝑥 − 𝑥1 =
𝑦 − 𝑦1
𝑦2 − 𝑦1
× 𝑥2 − 𝑥1
𝑥 =
𝑦−𝑦1
𝑦2−𝑦1
∗ 𝑥2 − 𝑥1 + 𝑥1
2. Egde Flag Scanline Algorithm
Before Edge Flag Fill
After Edge Flag Fill
negate
2. Egde Flag Scanline Algorithm
Y max
Y min
Xmin=0 Xmax
3. Egde Fill Scanline Algorithm
1. For each Scan line intersecting a polygon edge at(x, y),
i. Complement all pixels to the right of (x, y).
2. Next Scan line go to step 1.
4. Fence Fill Scanline Algorithm
1. For each Scan line intersecting a polygon edge at(x, y),
i. If the intersection is to the left of fence,
a) Complement all pixels to the right of (x, y) of scan line
and edge and to the left of fence.
ii. If the intersection is to the right of fence,
b) Complement all pixels to the left of (x, y) of scan line
and edge and to the right of fence.
2. Next Scan line go to step 1.
4. Fence Fill Scanline Algorithm
5. Boundary Fill Algorithm
• Boundary Fill Algorithm starts at a pixel inside the polygon to
be filled and paints the interior proceeding outwards towards
the boundary.
• This algorithm works only if the color with which the region
has to be filled and the color of the boundary of the region are
different.
• If the boundary is of one single color, this approach proceeds
outwards pixel by pixel until it hits the boundary of the
region.
5. Boundary Fill Algorithm
• Boundary Fill Algorithm is recursive in nature.
• It takes an interior point(x, y), a fill color, and a boundary color
as the input.
1. The algorithm starts by checking the color of (x, y).
i. If it’s color is not equal to the fill color and the boundary
color, then it is painted with the fill color and
ii. the function is called for all the neighbours of (x, y)
recursively.
2. This process continues until all points up to the boundary
color for the region have been tested.
5. 4-connected pixels Boundary Fill Algorithm
4-connected pixels Boundary Fill Algorithm :
• After painting a pixel, the function is called for four neighboring
points.
• These are the pixel positions that are right, left, above and below
the current pixel.
• Areas filled by this method are called 4-connected.
void boundaryFill4(int x, int y, int fill_color,int boundary_color)
{
if(getpixel(x, y) != boundary_color &&
getpixel(x, y) != fill_color)
{
putpixel(x, y, fill_color);
boundaryFill4(x + 1, y, fill_color, boundary_color);
boundaryFill4(x, y + 1, fill_color, boundary_color);
boundaryFill4(x - 1, y, fill_color, boundary_color);
boundaryFill4(x, y - 1, fill_color, boundary_color);
}
}
5. 8-connected pixels Boundary Fill Algorithm
8-connected pixels :
• More complex figures are filled using this approach.
• The pixels to be tested are the 8 neighboring pixels, the pixel on the
right, left, above, below and the 4 diagonal pixels.
• Areas filled by this method are called 8-connected.
5. 8-connected pixels Boundary Fill Algorithm
Below given is the algorithm :
void boundaryFill8(int x, int y, int fill_color,int boundary_color)
{
if(getpixel(x, y) != boundary_color && getpixel(x, y) != fill_color)
{
putpixel(x, y, fill_color);
boundaryFill8(x + 1, y, fill_color, boundary_color);
boundaryFill8(x, y + 1, fill_color, boundary_color);
boundaryFill8(x - 1, y, fill_color, boundary_color);
boundaryFill8(x, y - 1, fill_color, boundary_color);
boundaryFill8(x - 1, y - 1, fill_color, boundary_color);
boundaryFill8(x - 1, y + 1, fill_color, boundary_color);
boundaryFill8(x + 1, y - 1, fill_color, boundary_color);
boundaryFill8(x + 1, y + 1, fill_color, boundary_color);
}
}
6. Flood Fill Algorithm or Seed fill Algorithm
Sometimes it is required to fill in an area that is not defined within
a single color boundary.
In such cases we can fill areas by replacing a specified interior color
instead of searching for a boundary color. This approach is called a
flood-fill algorithm.
• Like boundary fill algorithm, here we start with some seed and
examine the neighboring pixels
• However, here pixels are checked for a specified interior color
instead of boundary color and they are replaced by new color.
• Using either a 4-connected or 8-connected approach, we can stop
through pixel positions until all interior point have been filled.
6. Flood Fill Algorithm or Seed fill Algorithm
Recursive algorithm for seed fill methods have difficulty as -
• The first difficulty is that if some inside pixels are already
displayed in fill color then recursive branch terminates,
leaving further internal pixels unfilled.
• If the image size increases the complexity increases in
recurssion.
To avoid this difficulty, we have to first change the color of any
internal pixels that are initially set to the fill color before applying
the seed fill procedures
Disadvantage:
• Very slow algorithm
• May be fail for large polygons
• Initial pixel required more knowledge about surrounding pixels.
6. Flood Fill Algorithm or Seed fill Algorithm
Procedure floodfill (x, y,fill_ color, old_color: integer)
If (getpixel (x, y)=old_color)
{
setpixel (x, y, fill_color);
fill (x+1, y, fill_color, old_color);
fill (x-1, y, fill_color, old_color);
fill (x, y+1, fill_color, old_color);
fill (x, y-1, fill_color, old_color);
}
}
Terminologies in Computer Graphics
1. Scree/Display Resolution: The number of horizontal and
vertical pixels on a display screen. Also known
as display mode.
OR
1. Screen resolution is the number of pixels a screen can show,
both horizontally and vertically.
• The more pixels, the more information is visible without
scrolling.
• Screen resolutions have a pixel count such as 1600x1200,
which means 1600 horizontal pixels & 1200 vertical pixels.
Terminologies in Computer Graphics
1. The aspect ratio of a display device is the proportional
relationship between the width and the height of the display. It
is expressed as two numbers separated by a colon (x:y).
Common aspect ratios for displays, past and present, include
5:4, 4:3, 16:10 and 16:9.
Frame Buffer
• A frame buffer is large contiguous piece of computer memory which is
used to store the display image.
• The diff kinds of memory used for frame buffers are disk, IC shift
registers, drums etc.
• To display a pixel on raster display, minimum 1 bit is used in frame
buffer for text to maximum 24 bit in a frame buffer for graphics.
• When 1 bit is used to generate a pixel, the picture will be Black and
white(0 & 1).
• A frame buffer stores information in digital form while raster display
requires voltage to generate pixel. A single bit frame buffer raster CRT
display is as following fig.
Frame Buffer
• Single Bit Frame Buffer
Frame Buffer Continued
• If the bits are increased from 1 to n then 2n intensity level can be
achieved, for this, all the n bits are checked and resulting value is
calculated.
• This value is given to DAC to generate appropriate voltage to set
intensity of the pixel on the raster
Frame Buffer
• N- Bit plane Gray level Frame Buffer
Frame Buffer
• N- Bit plane Gray level Frame Buffer
Frame Buffer
• N- Bit plane Gray level Frame Buffer
Frame Buffer
• Simple color Frame Buffer
Color Frame Buffer
• 24-bit Plane color Frame Buffer
Frame Buffer Continued
Rotating memory Frame Buffer
• Drums and disks were widely used in frame buffers to store the image
information.
• It is required to be refreshed continuously. Thus, it is necessary to read
the disk or drum again and again to refresh display.
• For this the rotating speed is made to coincide with the refresh rate of
the screen.
• To generate a pixel of desired intensity or colour, it is first necessary to
read the disk or drum.
Frame Buffer Continued
Rotating memory Frame Buffer Continued
• The information stored in disk or drum is in digital form, hence it is
necessary to convert it into analog form using DAC and then this
analog signal is used to generate the pixel.
• If only one bit is used to generate the pixel then only black and white
picture is possible.
• Disadvantage:- 1) the cost of the memory is high. 2) It requires more
time due to latency problem.
Frame Buffer Continued
Shift register Frame Buffer
•It is IC, the problem with the rotating memory is that it is slow and
expensive while IC-shift register can perform the same task with better
speed and is less expensive.
•In this circuit, when pulse is applied, the content of memory are shifted
by one place removing the last bit and inserting it into the starting bit.
•It is rotating the information in a circular form.
Frame Buffer Continued
Shift register Frame Buffer
•In this, one bit of memory is used as an intensity value.
•For color or gray scale display more than one IC, shift register can be
used in parallel.
•Disadvantage: 1) It requires more time due to latency problem.
2)In shift-register, even small changes requires more time.
Frame Buffer Continued
Random Access Frame Buffer
• Frame buffers are made up of random access circuit, and the color or
gray scale of the pixel can be set by 1,2,4,8 or more bits.
• 1 bit is generally used in text generation and any simple 2-D graphics
figures like square, triangle.
• To fill up the graphics figure, 2 to 4 bits of information are required for
diff types of shading effects while 8 or more bits are used for high
quality graphics.
• In color display 3 guns are used for 3 primary colors .E.g.- Red, Green,
Blue, one for each.
Character Generation
Techniques
Characters Generation in CG
In computer graphics character can be generated
using software.
In hardware implementation of character generation
limited faces of character can be generated.
A wide variety of faces of character can be
generated with software implementation.
There are three methods for generating
characters using software implementation:-
 Stroke method
 Vector method or bitmap method.
 Star bust method
Stroke Method
 In this method we use a sequence of line drawing function
and arc functions to generate characters.
 We can generate a sequence of character by assigning starting
and end point of line or arc.
 By using this method various faces of character can be
generated by changing the values (parameters) in line and arc
function.
 We can build our own stroke method character generator by
calls to the line drawing algorithm.
 Here it is necessary to decide which line segments are needed
for each character and then drawing these segments using line
drawing algorithm.
 Eg:-
Starbust Method
 In this method a fixed pattern of line is used to generate the
character.
 In this method we use a combination of 24 bit line segment.
 In 24 bit line segment code each bit represent a single line.
 Out of these 24 line segments, segments required to display for
particular character are highlighted.
To highlight a line we put corresponding bit 1 in 24 bit line segment
code and 0 otherwise.
Representaion of Starbust Method:
• The starbust patterns for characters A and M. the patterns for
particular characters are stored in the form of 24 bit code, each
bit representing one line segment.
• The bit is set to one to highlight the line segment; otherwise it is
set to zero.
• For example, 24-bit code for Character A is 0011 0000 0011
1100 1110 0001 and for character M is 0000 0011 0000 1100
Representaion of Starbust Method:
• This method of character generation has some disadvantages. They are
1. The 24-bits are required to represent a character. Hence more memory is
required
2. Requires code conversion software to display character from its 24-bit code
3. Character quality is poor. It is worst for curve shaped characters.
4. In Starbust method, 24 bit segment code is required to put in memory for
generating character. Hence extra memory is required in this method .
Bitmap Method
 This method is suitable for producing various character.
 Font size of character can be increased by increasing the size of
array.
 This method uses an array of 1’s & 0’s to represent pixels.
 It is also called dot matrix because in this method characters are
represented by an array of dots in the matrix form.
 It is a two dimensional array having columns and rows.
 An 5x7 array is commonly used to represent characters.
 However 7x9 and 9x13 arrays are also used.
 Higher resolution devices such as inkjet printer or laser printer
may use character arrays that are over 100x100.
Example of an Bitmap Array:
All the mentioned methods creates aliased characters:
Polygon
Polyline is a chain of connected line segments. It is
specified by giving the vertices P0, P1, P2..and so on.
The first vertex is called initial point and last is called
terminal point.
P0 P2
102
P1
P3
P4
P5
P6
Polygon
When initial point and terminal point of any polyline
is same (when polyline is closed) then it is called
polygon.
103
104
• Polygon is a representation of the surface.
• It is primitive which is closed in nature.
• It is formed using a collection of lines.
• It is also called as many-sided figure.
• The lines combined to form polygon are called sides or edges.
The lines are obtained by combining two vertices.
About Polygon
105
Types of Polygon
1. Regular Polygon a regular polygon is a polygon
that is equiangular (all angles are equal in measure)
and equilateral (all sides have the same length).
Regular polygons may be either convex or star.
106
Types of Polygon
2. Convex polygon is a polygon in which the line
segment joining any two points within the polygon lies
completely inside the polygon
107
3. Concave polygon is a polygon in which the line
segment joining any two points within the polygon may
not lie completely inside the polygon.
108
Types of Polygon
4. Complex polygon is a concave type polygon with
number of edges and the edges are intersected.
109
Types of Polygon
Polygon Representation
110
The polygon can be represented by listing its n
vertices in an ordered list.
P = {(x1, y1), (x2, y2), ……., (xn, yn)}.
The polygon can be displayed by drawing a line
between (x1, y1), and (x2, y2), then a line between
(x2, y2), and (x3, y3), and so on until the end vertex.
In order to close up the polygon, a line between (xn,
yn), and (x1, y1) must be drawn.
One problem with this representation is that if we
wish to translate the polygon, it is necessary to
apply the translation transformation to each vertex
in order to obtain the translated polygon.

More Related Content

Similar to Study on Fundamentals of Raster Scan Graphics

Line drawing Algorithm DDA in computer Graphics.pdf
Line drawing Algorithm DDA in computer Graphics.pdfLine drawing Algorithm DDA in computer Graphics.pdf
Line drawing Algorithm DDA in computer Graphics.pdfRAJARATNAS
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2SanthiNivas
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygonsaa11bb11
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons dericationKumar
 
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohichapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi54MahakBansal
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptxAhmadAbba6
 
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- ButkarComputer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- ButkarVishal Butkar
 
Unit 2
Unit 2Unit 2
Unit 2ypnrao
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithmnehrurevathy
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimediasaranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivessaranyan75
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxIndhuMcamphil
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxAlamelu
 

Similar to Study on Fundamentals of Raster Scan Graphics (20)

Line drawing Algorithm DDA in computer Graphics.pdf
Line drawing Algorithm DDA in computer Graphics.pdfLine drawing Algorithm DDA in computer Graphics.pdf
Line drawing Algorithm DDA in computer Graphics.pdf
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
Bresenham circlesandpolygons
Bresenham circlesandpolygonsBresenham circlesandpolygons
Bresenham circlesandpolygons
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
 
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohichapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptx
 
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
 
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- ButkarComputer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
 
Unit 2
Unit 2Unit 2
Unit 2
 
99995320.ppt
99995320.ppt99995320.ppt
99995320.ppt
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Lect14 lines+circles
Lect14 lines+circlesLect14 lines+circles
Lect14 lines+circles
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
 
OUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptxOUTPUT PRIMITIVES.pptx
OUTPUT PRIMITIVES.pptx
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 

More from ChandrakantDivate1

Web Technology LAB MANUAL for Undergraduate Programs
Web Technology  LAB MANUAL for Undergraduate ProgramsWeb Technology  LAB MANUAL for Undergraduate Programs
Web Technology LAB MANUAL for Undergraduate ProgramsChandrakantDivate1
 
UNIVERSAL HUMAN VALUES- Harmony in the Nature
UNIVERSAL HUMAN VALUES- Harmony in the NatureUNIVERSAL HUMAN VALUES- Harmony in the Nature
UNIVERSAL HUMAN VALUES- Harmony in the NatureChandrakantDivate1
 
Study of Computer Hardware System using Block Diagram
Study of Computer Hardware System using Block DiagramStudy of Computer Hardware System using Block Diagram
Study of Computer Hardware System using Block DiagramChandrakantDivate1
 
Computer System Output Devices Peripherals
Computer System Output  Devices PeripheralsComputer System Output  Devices Peripherals
Computer System Output Devices PeripheralsChandrakantDivate1
 
Computer system Input Devices Peripherals
Computer system Input  Devices PeripheralsComputer system Input  Devices Peripherals
Computer system Input Devices PeripheralsChandrakantDivate1
 
Computer system Input and Output Devices
Computer system Input and Output DevicesComputer system Input and Output Devices
Computer system Input and Output DevicesChandrakantDivate1
 
Introduction to COMPUTER’S MEMORY RAM and ROM
Introduction to COMPUTER’S MEMORY RAM and ROMIntroduction to COMPUTER’S MEMORY RAM and ROM
Introduction to COMPUTER’S MEMORY RAM and ROMChandrakantDivate1
 
Introduction to Computer Hardware Systems
Introduction to Computer Hardware SystemsIntroduction to Computer Hardware Systems
Introduction to Computer Hardware SystemsChandrakantDivate1
 
Fundamentals of Internet of Things (IoT) Part-2
Fundamentals of Internet of Things (IoT) Part-2Fundamentals of Internet of Things (IoT) Part-2
Fundamentals of Internet of Things (IoT) Part-2ChandrakantDivate1
 
Fundamentals of Internet of Things (IoT)
Fundamentals of Internet of Things (IoT)Fundamentals of Internet of Things (IoT)
Fundamentals of Internet of Things (IoT)ChandrakantDivate1
 
Introduction to Artificial Intelligence ( AI)
Introduction to Artificial Intelligence ( AI)Introduction to Artificial Intelligence ( AI)
Introduction to Artificial Intelligence ( AI)ChandrakantDivate1
 
Fundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptxFundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptxChandrakantDivate1
 
Fundamentals of Structure in C Programming
Fundamentals of Structure in C ProgrammingFundamentals of Structure in C Programming
Fundamentals of Structure in C ProgrammingChandrakantDivate1
 
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN CINPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN CChandrakantDivate1
 
Programming in C - Fundamental Study of Strings
Programming in C - Fundamental Study of  StringsProgramming in C - Fundamental Study of  Strings
Programming in C - Fundamental Study of StringsChandrakantDivate1
 
Basics of Control Statement in C Languages
Basics of Control Statement in C LanguagesBasics of Control Statement in C Languages
Basics of Control Statement in C LanguagesChandrakantDivate1
 
Features and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for BeginnersFeatures and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for BeginnersChandrakantDivate1
 
Basics of Programming Algorithms and Flowchart
Basics of Programming Algorithms and FlowchartBasics of Programming Algorithms and Flowchart
Basics of Programming Algorithms and FlowchartChandrakantDivate1
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesChandrakantDivate1
 
Computer Graphics Three-Dimensional Geometric Transformations
Computer Graphics Three-Dimensional Geometric TransformationsComputer Graphics Three-Dimensional Geometric Transformations
Computer Graphics Three-Dimensional Geometric TransformationsChandrakantDivate1
 

More from ChandrakantDivate1 (20)

Web Technology LAB MANUAL for Undergraduate Programs
Web Technology  LAB MANUAL for Undergraduate ProgramsWeb Technology  LAB MANUAL for Undergraduate Programs
Web Technology LAB MANUAL for Undergraduate Programs
 
UNIVERSAL HUMAN VALUES- Harmony in the Nature
UNIVERSAL HUMAN VALUES- Harmony in the NatureUNIVERSAL HUMAN VALUES- Harmony in the Nature
UNIVERSAL HUMAN VALUES- Harmony in the Nature
 
Study of Computer Hardware System using Block Diagram
Study of Computer Hardware System using Block DiagramStudy of Computer Hardware System using Block Diagram
Study of Computer Hardware System using Block Diagram
 
Computer System Output Devices Peripherals
Computer System Output  Devices PeripheralsComputer System Output  Devices Peripherals
Computer System Output Devices Peripherals
 
Computer system Input Devices Peripherals
Computer system Input  Devices PeripheralsComputer system Input  Devices Peripherals
Computer system Input Devices Peripherals
 
Computer system Input and Output Devices
Computer system Input and Output DevicesComputer system Input and Output Devices
Computer system Input and Output Devices
 
Introduction to COMPUTER’S MEMORY RAM and ROM
Introduction to COMPUTER’S MEMORY RAM and ROMIntroduction to COMPUTER’S MEMORY RAM and ROM
Introduction to COMPUTER’S MEMORY RAM and ROM
 
Introduction to Computer Hardware Systems
Introduction to Computer Hardware SystemsIntroduction to Computer Hardware Systems
Introduction to Computer Hardware Systems
 
Fundamentals of Internet of Things (IoT) Part-2
Fundamentals of Internet of Things (IoT) Part-2Fundamentals of Internet of Things (IoT) Part-2
Fundamentals of Internet of Things (IoT) Part-2
 
Fundamentals of Internet of Things (IoT)
Fundamentals of Internet of Things (IoT)Fundamentals of Internet of Things (IoT)
Fundamentals of Internet of Things (IoT)
 
Introduction to Artificial Intelligence ( AI)
Introduction to Artificial Intelligence ( AI)Introduction to Artificial Intelligence ( AI)
Introduction to Artificial Intelligence ( AI)
 
Fundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptxFundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptx
 
Fundamentals of Structure in C Programming
Fundamentals of Structure in C ProgrammingFundamentals of Structure in C Programming
Fundamentals of Structure in C Programming
 
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN CINPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
 
Programming in C - Fundamental Study of Strings
Programming in C - Fundamental Study of  StringsProgramming in C - Fundamental Study of  Strings
Programming in C - Fundamental Study of Strings
 
Basics of Control Statement in C Languages
Basics of Control Statement in C LanguagesBasics of Control Statement in C Languages
Basics of Control Statement in C Languages
 
Features and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for BeginnersFeatures and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for Beginners
 
Basics of Programming Algorithms and Flowchart
Basics of Programming Algorithms and FlowchartBasics of Programming Algorithms and Flowchart
Basics of Programming Algorithms and Flowchart
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
Computer Graphics Three-Dimensional Geometric Transformations
Computer Graphics Three-Dimensional Geometric TransformationsComputer Graphics Three-Dimensional Geometric Transformations
Computer Graphics Three-Dimensional Geometric Transformations
 

Recently uploaded

Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdfKamal Acharya
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectRased Khan
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopEmre Günaydın
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...Amil baba
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industriesMuhammadTufail242431
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxVishalDeshpande27
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdfKamal Acharya
 
A case study of cinema management system project report..pdf
A case study of cinema management system project report..pdfA case study of cinema management system project report..pdf
A case study of cinema management system project report..pdfKamal Acharya
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringC Sai Kiran
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamDr. Radhey Shyam
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringDr. Radhey Shyam
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfPipe Restoration Solutions
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdfKamal Acharya
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.PrashantGoswami42
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdfAhmedHussein950959
 
Scaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltageScaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltageRCC Institute of Information Technology
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxMd. Shahidul Islam Prodhan
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdfKamal Acharya
 
Electrostatic field in a coaxial transmission line
Electrostatic field in a coaxial transmission lineElectrostatic field in a coaxial transmission line
Electrostatic field in a coaxial transmission lineJulioCesarSalazarHer1
 

Recently uploaded (20)

Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker project
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptx
 
School management system project report.pdf
School management system project report.pdfSchool management system project report.pdf
School management system project report.pdf
 
A case study of cinema management system project report..pdf
A case study of cinema management system project report..pdfA case study of cinema management system project report..pdf
A case study of cinema management system project report..pdf
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Scaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltageScaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltage
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Electrostatic field in a coaxial transmission line
Electrostatic field in a coaxial transmission lineElectrostatic field in a coaxial transmission line
Electrostatic field in a coaxial transmission line
 

Study on Fundamentals of Raster Scan Graphics

  • 1. Unit 2: Raster Scan Graphics Mr. C. P. Divate
  • 2. Line generation Algorithm in Computer Graphics • In any 2-Dimensional plane if we connect two points (x1, y1) and (x2, y2), we get a line segment. • But in the case of computer graphics we can not directly join any two coordinate points, for that we should calculate intermediate point’s coordinate and put a pixel for each intermediate point, of the desired color with help of functions like putpixel(x, y, K) in C, where (x,y) is our co- ordinate and K denotes some color. Examples: Input: For line segment between (3, 2) and (6, 5) : we need (3, 2),(4, 2) (4, 3) ….. (5, 5) as our intermediate points.
  • 3. Line generation Two-point form equation of line Computer Graphics • Let P(x,y) be the general point on the line L which passes through the points A(x1,y1) and B(x2,y2)
  • 4. Basic properties of line drawing in Computer Graphics The primary design criteria are as follows.  Straight lines appear as straight lines.  Straight lines start and end accurately.  Displayed lines should have constant brightness along their length, independent of the line length and orientation.  Lines should be drawn rapidly.
  • 5. Basic mathematics to draw line drawing in Computer Graphics Method-1 : Direct Method : In this algorithm, we have two endpoints. We find the slope of the line by using both the points, and we put the slope in the line equation y = mx + b.
  • 6. Basic properties of line drawing ALGORITHMS in Computer Graphics An algorithm should be precise: Each step of the algorithm must be adequately defined. Finiteness: An algorithm must contain finiteness. It means the algorithm stops after the execution of all steps. Easy to understand: An algorithm must help learners to understand the solution in a more natural way. Correctness: An algorithm must be in the correct manner. Effectiveness: Thesteps of an algorithm must be valid and efficient. Uniqueness: All steps of an algorithm should be clearly and uniquely defined, and the result should be based on the given input. Input: A good algorithm must accept at least one or more input. Output: An algorithm must generate at least one output.
  • 7. DDA Line Generation Two-point form equation of line Computer Graphics
  • 8. DDA Line generation Two-point form equation of line Computer Graphics DDA Algorithm: Step 1: Start Algorithm Step 2: Declare x1,y1,x2,y2,dx,dy,x,y as integer variables. Step 3: Enter value of x1,y1,x2,y2. Step 4: if ABS (x2-x1) > ABS (y2-y1) Then step = abs (x2-x1) else step = abs (y2-y1) Step 5: dx=(x2-x1)/step dy=(y2-y1)/step assign x = x1 + 0.5 assign y = y1 + 0.5 i=1 Step 6: Set pixel (x, y) Step 7: while( i <= step ) x = x + dx y = y + dy i=i+1 Set pixels (Round (x), Round (y)) Step 8: End Algorithm Example draw line from (0,0) to (4,6) dx=0.7 dy=1 step=6
  • 9. DDA Line generation Two-point form equation of line Computer Graphics DDA Algorithm: Step 1: Start Algorithm Step 2: Declare x1,y1,x2,y2,dx,dy,x,y as integer variables. Step 3: Enter value of x1,y1,x2,y2. Step 4: if ABS (x2-x1) > ABS (y2-y1) Then step = abs (x2-x1) else step = abs (y2-y1) Step 5: dx=(x2-x1)/step dy=(y2-y1)/step assign x = x1 + 0.5 assign y = y1 + 0.5 i=1 Step 6: Set pixel (x, y) Step 7: while( i <= step ) x = x + dx y = y + dy i=i+1 Set pixels (Round (x), Round (y)) Step 8: End Algorithm Example draw line from p1(2,3) to p2(6,6) i ( x , y ) x y
  • 10. DDA Line generation Two-point form equation of line Computer Graphics Advantages : i. It is simple and easy to implement algorithm. ii. It avoid using multiple operations which have high time complexities. iii. It is faster than the direct use of the line equation because it does not use any floating point multiplication and it calculates points on the line. Disadvantages : i. It deals with the rounding off operation and floating point arithmetic so it has high time complexity. ii. As it is orientation dependent, so it has poor endpoint accuracy. iii. Due to the limited precision in the floating point representation it produces cumulative error.
  • 11. Basis of the algorithm: A B Start position From start position decide A or B next • A more efficient approach • It is suited for implementation on CRT device. • The algorithm seeks to select optimum(accurate) raster location to draw straight line. • For this algorithm increments either x or y by one depending on slope of line.
  • 12. Basis of the algorithm: A B Start position From start position decide A or B next • The increment in other variable ,either 0 or 1is determined by actual line and distance between the actual line and nearest grid location. • This distance is called error e
  • 13. For a given value of x • If the slope of line is greater than or equal to ½ then line intercept at x=1 is closer to y=1. • If the slope of line is less than ½ then line intercept at x=1 is closer to y=0. • Reason is, one pixel lies at distance ti above the line, and one pixel lies at distance si below theline Trueline ti si • The increment in other variable ,either 0 or 1is determined by actual line and distance between the actual line and nearest grid location. • This distance is called error e 1 2 ≤ Δ𝑦 Δ𝑥 ≤ 1 𝑒 ≥ 0 𝑝𝑙𝑜𝑡 1,1 0 ≤ Δ𝑦 Δ𝑥 < 1 2 𝑒 < 0 𝑝𝑙𝑜𝑡 1,0 1 2 Δ𝑦 Δ𝑥 1 0
  • 14. For a given value of x • If the slope of line is greater than or equal to ½ then line intercept at x=1 is closer to y=1. • If the slope of line is less than ½ then line intercept at x=1 is closer to y=0. • Reason is, one pixel lies at distance ti above the line, and one pixel lies at distance si below theline Trueline ti si • The increment in other variable ,either 0 or 1is determined by actual line and distance between the actual line and nearest grid location. • This distance is called error e 1 2 ≤ Δ𝑦 Δ𝑥 ≤ 1 𝑒 ≥ 0 𝑝𝑙𝑜𝑡 1,1 0 ≤ Δ𝑦 Δ𝑥 < 1 2 𝑒 < 0 𝑝𝑙𝑜𝑡 1,0 1 2 Δ𝑦 Δ𝑥 1 0
  • 15. For a given value of x • If the slope of line is greater than or equal to ½ then line intercept at x=1 is closer to y=1. • If the slope of line is less than ½ then line intercept at x=1 is closer to y=0. • Reason is, one pixel lies at distance ti above the line, and one pixel lies at distance si below theline Trueline ti si • The increment in other variable ,either 0 or 1is determined by actual line and distance between the actual line and nearest grid location. • This distance is called error e 1 2 ≤ Δ𝑦 Δ𝑥 ≤ 1 𝑒 ≥ 0 𝑝𝑙𝑜𝑡 1,1 0 ≤ Δ𝑦 Δ𝑥 < 1 2 𝑒 < 0 𝑝𝑙𝑜𝑡 1,0 1 2 Δ𝑦 Δ𝑥 1 0
  • 16. Bresenham Line Algorithm The algorithm start with error term with following error term equation, e = m - ½ Subsequent increments in e will be e = e + m
  • 17. LineBres(int x1, int y1, int x2, int y2) // line for |m| < 1 { Step 1: Start Algorithm Step 2: Declare x1, y1, x2, y2, dx, dy, x, y as integer variables. Step 3: dx = x2 – x1, dy = y2 – y1, x=x1, y=y1 m=dy /dx e = m – ½ Step 4: for i= 0 to dx { setpixel (x,y) while(e>0) { y = y+1 e=e-1 } x=x+1 e=e+m next I Setp 5: Finish Floating point Bresenham’s Line Algorithm:
  • 18. e = m – ½ e = 𝑑𝑦 𝑑𝑥 - 1 2 ( where m= 𝑑𝑦 𝑑𝑥 ) e = 2 𝑑𝑦 − 𝑑𝑥 2 𝑑𝑥 2dx e = 2 dy - dx - ( I ) Here let, ê = 2dx e - ( II ) Hence, ê = 2 dy - dx - ( III ) Integer Bresenham’s Line Algorithm: e = e + m e = e + 𝑑𝑦 𝑑𝑥 e = e dx + dy 𝑑𝑥 e dx = e dx + dy Multiply both side by 2 2e dx = 2e dx + 2 dy – (IV) Use eqn ( III ) in ( IV ) ê = ê + 2 dy - ( V ) Convert following floating point equations to integer equation to run algorithm fast, e = m – ½ e=e+m e=e-1
  • 19. e=e-1 - ( V ) Multiply both side of ( V ) by 2.dx 2 dx e = 2 dx e - 2dx - ( V ) As, ê = 2dx e - ( II ) Hence, ê = ê - 2dx - ( III ) Integer Bresenham’s Line Algorithm: Convert following floating point equations to integer equation to run algorithm fast, e = m – ½ e=e+m e=e-1
  • 20. LineBres(int x1, int y1, int x2, int y2) // line for |m| < 1 Step 1: Declare x1, y1, x2, y2, dx, dy, x, y as integer variables. Step 2: dx = x2 – x1, dy = y2 – y1, x = x1, y = y1 ê = 2 dy - dx Step 3: for i= 0 to dx step i = i + 1 { setpixel (x,y) while( ê >0) { y = y+1 ê = ê - 2dx } x=x+1 ê = ê + 2 dy } Setp 5: Finish LineBres Integer Bresenham’s Line Algorithm:
  • 21. General Bresenham’s Line Algorithm: Depending on quadrant the increment / decrement in x and y will be as above
  • 24. Advantages / disadvantages of Bresenham Line Algorithm: The advantages of Bresenham Line Drawing Algorithm are- • It is easy to implement. • It is fast and incremental. • It executes fast but less faster than DDA Algorithm. • The points generated by this algorithm are more accurate than DDA Algorithm. • It uses fixed points only. The disadvantages of Bresenham Line Drawing Algorithm are- • Though it improves the accuracy of generated points but still the resulted line is not smooth. • This algorithm is for the basic line drawing. • It can not handle diminishing jaggies.
  • 25. Basic Concepts in Circle Drawing  Circle is a symmetrical figure.  The shape of the circle is similar in each quadrant  It has eight-way symmetry 1) Plot (x,y) 2) Plot (y,x) 3) Plot (-x,-y) 4) Plot (-y,-x) 5) Plot (-x,y) 6) Plot (y, -x) 7) Plot (x,-y) 8) Plot (-y,x) 25
  • 26. • Polynomial Method • x2 + y2 = r2 • Trigonometric Method • x= r cos Ө • Y = r sin Ө 26 Methods to Represent a Circle r r
  • 27. General Bresenham’s Circle Algorithm: • Most efficient algorithm to draw circle is Bresenham’s Circle Algorithm. • The Bresenham’s circle drawing algorithm considers the eight way of the symmetry of the circle to generate it.
  • 28. General Bresenham’s Circle Algorithm: • At the beginning only one octant of the circle generation is needed. • Other parts of circles are drawn by successive reflections. 1) e.g. if circle has drawn in first octant (0 to 450 ccw) 2) The second octant is obtained by reflection through the line y=x to yield first quadrant. 3) The results(pixels) in first quadrant are reflected through the line x=0 to obtain the second quadrant pixels. 4) The combined results (pixels) of upper semicircles are reflected through the line y = 0 to complete the circle.
  • 29. Bresenham’s Circle drawing Algorithm: 29 • It plots 1/8th part of the circle i.e. from 90ᵒto 45ᵒ. • As circle is drawn from 90ᵒ to 45ᵒ, the x moves in positive e direction and y moves in the negative direction.
  • 30. Bresenham’s Circle drawing Algorithm Actual Distance of raster pixel A and B from origin
  • 31. Bresenham’s Circle drawing Algorithm X i Y i Δ i
  • 32. Bresenham’s Circle drawing Algorithm X i Y i Δ i 1) If Δ i < 0 then, diagonal point is inside the actual circle, either pixel at (xi +1, yi) i.e. mH or that at (xi +1 , yi -1) i.e. mD must be chosen. To decide which own calculate δA = mH - mD A ---------- ( I ) ----- ( II ) A A Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 )
  • 33. Bresenham’s Circle drawing Algorithm Let us simplify, δA = mH - mD 𝝏𝑨 = | (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 𝟐 - R 2 | - | ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 - R 2 ) | 𝜕𝐴 = | ( (𝑥𝑖 + 1)2 + 𝒚𝒊 − 𝟏 𝟐 − R 2 ) | - | ( (𝑥𝑖 + 1)2 + 𝒚𝒊 − 𝟏 𝟐 - R 2) |+ (2𝒚𝒊 + 1) 𝜕𝐴 = 2| ( (𝑥𝑖 + 1)2 + 𝒚𝒊 − 𝟏 𝟐 − R 2 ) | + 2𝒚𝒊 + 1 𝜕𝐴 = 𝟐Δ 𝒊 + 2𝒚𝒊 + 1 𝜕𝐴 = | (𝑥𝑖 + 1)2 + 𝒚𝒊 2 − 2𝒚𝒊 - 1 - R 2 | - | ( (𝑥𝑖 + 1)2 + 𝑦𝑖 − 1 2 - R 2) |+ (2𝒚𝒊 + 1) 𝜕𝐴 = 𝟐 ( 𝜟 𝒊 + 𝒚𝒊 ) + 1 ---------[ III ] 𝜕𝐴 = | (𝑥𝑖 + 1)2 + 𝒚𝒊 2 − (2𝒚𝒊 + 1) - R 2 | - | ( (𝑥𝑖 + 1)2 + 𝑦𝑖 − 1 2 - R 2) |+ (2𝒚𝒊+1) Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 )
  • 34. Bresenham’s Circle drawing Algorithm X i Y i Δ i 2) If Δ i > 0 then, diagonal point is outside the actual circle, either pixel at (xi +1 , yi -1) i.e. mD or that at i.e. (xi yi + 1) mV must be chosen. To decide which own calculate δB = mD - mV Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 ) B B B
  • 35. Bresenham’s Circle drawing Algorithm Let us simplify, δA = mD - mV 𝝏𝑩 = | (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 - R 2 | - | ( x𝒊 2 + 𝒚𝒊 − 𝟏 𝟐 - R 2 ) | 𝜕𝐵 = | (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 | - | ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 - R 2) | − 2𝒙𝒊 − 1 𝜕𝐵 = 2| ( (𝑥𝑖 + 1)2 + 𝒚𝒊 − 𝟏 𝟐 − R 2 ) | - 2𝒙𝒊 - 1 𝜕𝐵 = 𝟐Δ 𝒊 − 2𝒚𝒊 − 1 𝜕𝐵 = | (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 | - | ( (𝑥𝑖 2 + 𝟐 𝒙 + 𝟏 + 𝑦𝑖 − 1 2 - R 2) | − 2x𝒊 − 1 𝜕𝐵 = 𝟐 ( 𝜟 𝒊 − 𝒙𝒊 ) - 1 ---------[ IV ] 𝜕𝐵 = | (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 | - | ( (𝑥𝑖 2 + (𝟐 𝒙 + 𝟏) + 𝑦𝑖 − 1 2 - R 2) | − (2x𝒊+1 Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 )
  • 36. Bresenham’s Circle drawing Algorithm X i Y i Δ i 3) If Δ i = 0 then, δA = mH – mD Here mD = Δ i = 0, hence δA = mH which means δA >=0 hence diagonal pixel ((𝒙𝒊 + 𝟏) , 𝒚𝒊 − 𝟏 ) is selected i.e movement is mD OR 3) If Δ i = 0 then, δB = mD - mV Here mD = Δ i = 0, hence δB = - mV which means δB < 0 hence diagonal pixel ((𝒙𝒊 + 𝟏) , 𝒚𝒊 − 𝟏 ) is selected i.e movement is mD Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 )
  • 37. Bresenham’s Circle drawing Algorithm X i Y i Δ i
  • 38. Bresenham’s Circle drawing Algorithm Letus make some simplification to obtain values for x, y, 𝜟 𝒊, δA, and δB to increment or decrement during the loop of algorithm. 1) For Horizontal mH Pixel selection
  • 39. Bresenham’s Circle drawing Algorithm Letus make some simplification to obtain values for x, y, 𝜟 𝒊, δA, and δB to increment or decrement during the loop of algorithm. 2) For Diagonal mD Pixel selection 3) For Diagonal mV Pixel selection
  • 40. Bresenham’s Circle drawing Algorithm Letus make some simplification to obtain values for x, y, 𝜟 𝒊, δA, and δB to increment or decrement during the loop of algorithm. 4) Initial stage or pixel from where Bresenham’s circle algorithm works X=0 Y=R Δ 𝒊 = ( (𝒙𝒊 + 𝟏)𝟐 + 𝒚𝒊 − 𝟏 𝟐 − R 2 ) Δ 𝒊 = ( 𝟎 + 𝟏)𝟐 + 𝑹 − 𝟏 𝟐 − R 2 ) Δ 𝒊 = 𝟏 + 𝑹𝟐 − 𝟐𝑹 + 𝟏 − R 2 Δ 𝒊 = 𝟐 − 2R 𝜟 𝒊 = 𝟐(𝟏 − R ) r (0,R)
  • 41. Bresenham’s Circle drawing Algorithm Flowchart
  • 43. Example on Bresenham’s Circle Algorithm
  • 44.
  • 45. Bresenham’s Circle drawing Algorithm Advantages of Bresenham's Circle Drawing Algorithm 1) The Bresenhem’s circle drawing algorithm uses integer arithmetic which makes the implementation less complex. 2) Due to its integer arithmetic, it is less time-consuming. 3) This algorithm is more accurate than any other circle drawing algorithm as it avoids the use of round off function. Disadvantages of Bresenham's Circle Drawing Algorithm 1) This algorithm does not produce smooth results due to its integer arithmetic as it fails to diminish the zigzags completely. 2) The Bresenhem’s circle drawing algorithm is not accurate in the case of drawing of complex graphical images.
  • 46. Polygon • Polyline is a chain of connected line segments. It is specified by giving the vertices P0, P1, P2..and so on. • The first vertex is called initial point and last is called terminal point. P0 P2 46 P1 P3 P4 P5 P6
  • 47. Polygon • When initial point and terminal point of any polyline is same (when polyline is closed) then it is called polygon. 47
  • 48. 48 • Polygon is a representation of the surface. • It is primitive which is closed in nature. • It is formed using a collection of lines. • It is also called as many-sided figure. • The lines combined to form polygon are called sides or edges. The lines are obtained by combining two vertices. About Polygon
  • 49. 49
  • 50. Types of Polygon 1. Regular Polygon a regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length). Regular polygons may be either convex or star. 50
  • 51. Types of Polygon 2. Convex polygon is a polygon in which the line segment joining any two points within the polygon lies completely inside the polygon 51
  • 52. 3. Concave polygon is a polygon in which the line segment joining any two points within the polygon may not lie completely inside the polygon. 52 Types of Polygon
  • 53. 4. Complex polygon is a concave type polygon with number of edges and the edges are intersected. 53 Types of Polygon
  • 54. Polygon Representation 54 The polygon can be represented by listing its n vertices in an ordered list. P = {(x1, y1), (x2, y2), ……., (xn, yn)}. The polygon can be displayed by drawing a line between (x1, y1), and (x2, y2), then a line between (x2, y2), and (x3, y3), and so on until the end vertex. In order to close up the polygon, a line between (xn, yn), and (x1, y1) must be drawn. One problem with this representation is that if we wish to translate the polygon, it is necessary to apply the translation transformation to each vertex in order to obtain the translated polygon.
  • 55. Polygon Filling Algorithm • An ordered list of vertices forms a polygon. • Polygon Filling :- The pixels that fall on the border of the polygon are determined and the pixels that fall inside are determined in order to color the polygon. • Polygons are easier to fill since they have linear boundaries. • Filling the polygon means highlighting all the pixels which lie inside the polygon with any color other than the background color.
  • 56. Point Inside Test – Even-Odd Method • Once the polygon is entered, we can draw the outline of the polygon using drawpoly() command in c/c++. • To show polygon as a solid object, it is needed to set the pixel inside the polygon as well as pixels on the boundary of it. • Now the question is, to determine whether the point /pixel is inside or outside of a polygon.
  • 57. Point Inside Test – Even-Odd Method • One simple method of doing this is to draw a horizontal line segment from left to the pixel and count how many intersections of the line segment with the polygon boundary occur. • If there are an odd number of intersections, then the point is inside, otherwise it is outside. • This method is called the even-odd method of determining polygon inside points. • This inside test or Even-Odd method is used in scan line method of polygon filling..
  • 58. Types of Polygon Filling Algorithm There are two basic approaches used to fill the polygon. 1. Ordered Edge List Algorithm 2. Edge Flag algorithm 3. Edge fill algorithm 4. Fence Fill algorithm
  • 59. Scanline Polygon Filling Algorithm • Scanline filling is basically filling up of polygons using horizontal lines or scanlines. • The purpose of the SLPF algorithm is to fill (color) the interior pixels of a polygon for each scanline. • This algorithm works by intersecting scanline with polygon edges and fills the polygon between pairs of intersections. • These intersection points are then sorted from left to right, and the corresponding positions between each intersection pair are set to the specified fill color.
  • 60. Requirements of all Scanline Fill Algorithm Find Polygon Bounding box for,  selection number of scanlines for scanning polygon  Selection of boundry limit for x co-ordinate for each scanline
  • 61. 1. Ordered Egde List Scanline Algorithm 1) Start with Ymax and move to Ymin or vice versa 2) For each scan line: a. Find the intersections of the scan line with all edges of the polygon. b. Sort the intersections by increasing x coordinate. c. Fill in all pixels between pairs of intersections Note For scan line number 8 the sorted list of x-coordinates is (2, 4, 9, 13) Therefore draw line b/w (2,4) & (9,13) Y max Y min
  • 62. 1. Ordered Egde List Scanline Fill Algorithm Challenges in filling the polygon  selection number of scanlines for scanning polygon  Selection of boundry limit for x co-ordinate for each scanline Scan line 7 Scan line 6 Scan line 3 Scan line 1 One intersection Three intersections Three intersections Number of intersections 7 3 1 SL7: 1 SL6 : 1, 2, 8 SL4 : 1, 4, 6, 8 SL3 : 1, 5, 8 SL2 : 1, 8 SL1 : 1, 2,3,4,5,6,7, 8 Ordered edge list of X for Scan Line • It will no support or work if scan line intersects for odd number of times to polygon • For horizontal line of polygon this algorithm give maximum no of intersections to scanline hence fail
  • 63. Scanline Fill Algorithm Challenges in filling the polygon  selection number of scanlines for scanning polygon  Selection of boundry limit for x co-ordinate for each scanline One intersection One intersection
  • 64. Scanline Fill Algorithm Challenges in filling the polygon We know that for every scan line we have to calculate x intersection with every polygon side. We can determine the next x intersection value as Bounding Box (x1,y1) (x2,y2) Intersecting point (x, y) Scan line y 𝑑𝑦 𝑑𝑥 = (𝑦2 − 𝑦1) (𝑥2 − 𝑥1) = (𝑦 − 𝑦1) (𝑥 − 𝑥1) 𝑥 − 𝑥1 = 𝑦 − 𝑦1 𝑦2 − 𝑦1 × 𝑥2 − 𝑥1 𝑥 = 𝑦−𝑦1 𝑦2−𝑦1 ∗ 𝑥2 − 𝑥1 + 𝑥1
  • 65. 2. Egde Flag Scanline Algorithm Before Edge Flag Fill After Edge Flag Fill negate
  • 66. 2. Egde Flag Scanline Algorithm Y max Y min Xmin=0 Xmax
  • 67. 3. Egde Fill Scanline Algorithm 1. For each Scan line intersecting a polygon edge at(x, y), i. Complement all pixels to the right of (x, y). 2. Next Scan line go to step 1.
  • 68. 4. Fence Fill Scanline Algorithm 1. For each Scan line intersecting a polygon edge at(x, y), i. If the intersection is to the left of fence, a) Complement all pixels to the right of (x, y) of scan line and edge and to the left of fence. ii. If the intersection is to the right of fence, b) Complement all pixels to the left of (x, y) of scan line and edge and to the right of fence. 2. Next Scan line go to step 1.
  • 69. 4. Fence Fill Scanline Algorithm
  • 70. 5. Boundary Fill Algorithm • Boundary Fill Algorithm starts at a pixel inside the polygon to be filled and paints the interior proceeding outwards towards the boundary. • This algorithm works only if the color with which the region has to be filled and the color of the boundary of the region are different. • If the boundary is of one single color, this approach proceeds outwards pixel by pixel until it hits the boundary of the region.
  • 71. 5. Boundary Fill Algorithm • Boundary Fill Algorithm is recursive in nature. • It takes an interior point(x, y), a fill color, and a boundary color as the input. 1. The algorithm starts by checking the color of (x, y). i. If it’s color is not equal to the fill color and the boundary color, then it is painted with the fill color and ii. the function is called for all the neighbours of (x, y) recursively. 2. This process continues until all points up to the boundary color for the region have been tested.
  • 72. 5. 4-connected pixels Boundary Fill Algorithm 4-connected pixels Boundary Fill Algorithm : • After painting a pixel, the function is called for four neighboring points. • These are the pixel positions that are right, left, above and below the current pixel. • Areas filled by this method are called 4-connected. void boundaryFill4(int x, int y, int fill_color,int boundary_color) { if(getpixel(x, y) != boundary_color && getpixel(x, y) != fill_color) { putpixel(x, y, fill_color); boundaryFill4(x + 1, y, fill_color, boundary_color); boundaryFill4(x, y + 1, fill_color, boundary_color); boundaryFill4(x - 1, y, fill_color, boundary_color); boundaryFill4(x, y - 1, fill_color, boundary_color); } }
  • 73. 5. 8-connected pixels Boundary Fill Algorithm 8-connected pixels : • More complex figures are filled using this approach. • The pixels to be tested are the 8 neighboring pixels, the pixel on the right, left, above, below and the 4 diagonal pixels. • Areas filled by this method are called 8-connected.
  • 74. 5. 8-connected pixels Boundary Fill Algorithm Below given is the algorithm : void boundaryFill8(int x, int y, int fill_color,int boundary_color) { if(getpixel(x, y) != boundary_color && getpixel(x, y) != fill_color) { putpixel(x, y, fill_color); boundaryFill8(x + 1, y, fill_color, boundary_color); boundaryFill8(x, y + 1, fill_color, boundary_color); boundaryFill8(x - 1, y, fill_color, boundary_color); boundaryFill8(x, y - 1, fill_color, boundary_color); boundaryFill8(x - 1, y - 1, fill_color, boundary_color); boundaryFill8(x - 1, y + 1, fill_color, boundary_color); boundaryFill8(x + 1, y - 1, fill_color, boundary_color); boundaryFill8(x + 1, y + 1, fill_color, boundary_color); } }
  • 75. 6. Flood Fill Algorithm or Seed fill Algorithm Sometimes it is required to fill in an area that is not defined within a single color boundary. In such cases we can fill areas by replacing a specified interior color instead of searching for a boundary color. This approach is called a flood-fill algorithm. • Like boundary fill algorithm, here we start with some seed and examine the neighboring pixels • However, here pixels are checked for a specified interior color instead of boundary color and they are replaced by new color. • Using either a 4-connected or 8-connected approach, we can stop through pixel positions until all interior point have been filled.
  • 76. 6. Flood Fill Algorithm or Seed fill Algorithm Recursive algorithm for seed fill methods have difficulty as - • The first difficulty is that if some inside pixels are already displayed in fill color then recursive branch terminates, leaving further internal pixels unfilled. • If the image size increases the complexity increases in recurssion. To avoid this difficulty, we have to first change the color of any internal pixels that are initially set to the fill color before applying the seed fill procedures Disadvantage: • Very slow algorithm • May be fail for large polygons • Initial pixel required more knowledge about surrounding pixels.
  • 77. 6. Flood Fill Algorithm or Seed fill Algorithm Procedure floodfill (x, y,fill_ color, old_color: integer) If (getpixel (x, y)=old_color) { setpixel (x, y, fill_color); fill (x+1, y, fill_color, old_color); fill (x-1, y, fill_color, old_color); fill (x, y+1, fill_color, old_color); fill (x, y-1, fill_color, old_color); } }
  • 78. Terminologies in Computer Graphics 1. Scree/Display Resolution: The number of horizontal and vertical pixels on a display screen. Also known as display mode. OR 1. Screen resolution is the number of pixels a screen can show, both horizontally and vertically. • The more pixels, the more information is visible without scrolling. • Screen resolutions have a pixel count such as 1600x1200, which means 1600 horizontal pixels & 1200 vertical pixels.
  • 79. Terminologies in Computer Graphics 1. The aspect ratio of a display device is the proportional relationship between the width and the height of the display. It is expressed as two numbers separated by a colon (x:y). Common aspect ratios for displays, past and present, include 5:4, 4:3, 16:10 and 16:9.
  • 80. Frame Buffer • A frame buffer is large contiguous piece of computer memory which is used to store the display image. • The diff kinds of memory used for frame buffers are disk, IC shift registers, drums etc. • To display a pixel on raster display, minimum 1 bit is used in frame buffer for text to maximum 24 bit in a frame buffer for graphics. • When 1 bit is used to generate a pixel, the picture will be Black and white(0 & 1). • A frame buffer stores information in digital form while raster display requires voltage to generate pixel. A single bit frame buffer raster CRT display is as following fig.
  • 81. Frame Buffer • Single Bit Frame Buffer
  • 82. Frame Buffer Continued • If the bits are increased from 1 to n then 2n intensity level can be achieved, for this, all the n bits are checked and resulting value is calculated. • This value is given to DAC to generate appropriate voltage to set intensity of the pixel on the raster
  • 83. Frame Buffer • N- Bit plane Gray level Frame Buffer
  • 84. Frame Buffer • N- Bit plane Gray level Frame Buffer
  • 85. Frame Buffer • N- Bit plane Gray level Frame Buffer
  • 86. Frame Buffer • Simple color Frame Buffer
  • 87. Color Frame Buffer • 24-bit Plane color Frame Buffer
  • 88. Frame Buffer Continued Rotating memory Frame Buffer • Drums and disks were widely used in frame buffers to store the image information. • It is required to be refreshed continuously. Thus, it is necessary to read the disk or drum again and again to refresh display. • For this the rotating speed is made to coincide with the refresh rate of the screen. • To generate a pixel of desired intensity or colour, it is first necessary to read the disk or drum.
  • 89. Frame Buffer Continued Rotating memory Frame Buffer Continued • The information stored in disk or drum is in digital form, hence it is necessary to convert it into analog form using DAC and then this analog signal is used to generate the pixel. • If only one bit is used to generate the pixel then only black and white picture is possible. • Disadvantage:- 1) the cost of the memory is high. 2) It requires more time due to latency problem.
  • 90. Frame Buffer Continued Shift register Frame Buffer •It is IC, the problem with the rotating memory is that it is slow and expensive while IC-shift register can perform the same task with better speed and is less expensive. •In this circuit, when pulse is applied, the content of memory are shifted by one place removing the last bit and inserting it into the starting bit. •It is rotating the information in a circular form.
  • 91. Frame Buffer Continued Shift register Frame Buffer •In this, one bit of memory is used as an intensity value. •For color or gray scale display more than one IC, shift register can be used in parallel. •Disadvantage: 1) It requires more time due to latency problem. 2)In shift-register, even small changes requires more time.
  • 92. Frame Buffer Continued Random Access Frame Buffer • Frame buffers are made up of random access circuit, and the color or gray scale of the pixel can be set by 1,2,4,8 or more bits. • 1 bit is generally used in text generation and any simple 2-D graphics figures like square, triangle. • To fill up the graphics figure, 2 to 4 bits of information are required for diff types of shading effects while 8 or more bits are used for high quality graphics. • In color display 3 guns are used for 3 primary colors .E.g.- Red, Green, Blue, one for each.
  • 94. Characters Generation in CG In computer graphics character can be generated using software. In hardware implementation of character generation limited faces of character can be generated. A wide variety of faces of character can be generated with software implementation. There are three methods for generating characters using software implementation:-  Stroke method  Vector method or bitmap method.  Star bust method
  • 95. Stroke Method  In this method we use a sequence of line drawing function and arc functions to generate characters.  We can generate a sequence of character by assigning starting and end point of line or arc.  By using this method various faces of character can be generated by changing the values (parameters) in line and arc function.  We can build our own stroke method character generator by calls to the line drawing algorithm.  Here it is necessary to decide which line segments are needed for each character and then drawing these segments using line drawing algorithm.  Eg:-
  • 96. Starbust Method  In this method a fixed pattern of line is used to generate the character.  In this method we use a combination of 24 bit line segment.  In 24 bit line segment code each bit represent a single line.  Out of these 24 line segments, segments required to display for particular character are highlighted. To highlight a line we put corresponding bit 1 in 24 bit line segment code and 0 otherwise.
  • 97. Representaion of Starbust Method: • The starbust patterns for characters A and M. the patterns for particular characters are stored in the form of 24 bit code, each bit representing one line segment. • The bit is set to one to highlight the line segment; otherwise it is set to zero. • For example, 24-bit code for Character A is 0011 0000 0011 1100 1110 0001 and for character M is 0000 0011 0000 1100
  • 98. Representaion of Starbust Method: • This method of character generation has some disadvantages. They are 1. The 24-bits are required to represent a character. Hence more memory is required 2. Requires code conversion software to display character from its 24-bit code 3. Character quality is poor. It is worst for curve shaped characters. 4. In Starbust method, 24 bit segment code is required to put in memory for generating character. Hence extra memory is required in this method .
  • 99. Bitmap Method  This method is suitable for producing various character.  Font size of character can be increased by increasing the size of array.  This method uses an array of 1’s & 0’s to represent pixels.  It is also called dot matrix because in this method characters are represented by an array of dots in the matrix form.  It is a two dimensional array having columns and rows.  An 5x7 array is commonly used to represent characters.  However 7x9 and 9x13 arrays are also used.  Higher resolution devices such as inkjet printer or laser printer may use character arrays that are over 100x100.
  • 100. Example of an Bitmap Array:
  • 101. All the mentioned methods creates aliased characters:
  • 102. Polygon Polyline is a chain of connected line segments. It is specified by giving the vertices P0, P1, P2..and so on. The first vertex is called initial point and last is called terminal point. P0 P2 102 P1 P3 P4 P5 P6
  • 103. Polygon When initial point and terminal point of any polyline is same (when polyline is closed) then it is called polygon. 103
  • 104. 104 • Polygon is a representation of the surface. • It is primitive which is closed in nature. • It is formed using a collection of lines. • It is also called as many-sided figure. • The lines combined to form polygon are called sides or edges. The lines are obtained by combining two vertices. About Polygon
  • 105. 105
  • 106. Types of Polygon 1. Regular Polygon a regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length). Regular polygons may be either convex or star. 106
  • 107. Types of Polygon 2. Convex polygon is a polygon in which the line segment joining any two points within the polygon lies completely inside the polygon 107
  • 108. 3. Concave polygon is a polygon in which the line segment joining any two points within the polygon may not lie completely inside the polygon. 108 Types of Polygon
  • 109. 4. Complex polygon is a concave type polygon with number of edges and the edges are intersected. 109 Types of Polygon
  • 110. Polygon Representation 110 The polygon can be represented by listing its n vertices in an ordered list. P = {(x1, y1), (x2, y2), ……., (xn, yn)}. The polygon can be displayed by drawing a line between (x1, y1), and (x2, y2), then a line between (x2, y2), and (x3, y3), and so on until the end vertex. In order to close up the polygon, a line between (xn, yn), and (x1, y1) must be drawn. One problem with this representation is that if we wish to translate the polygon, it is necessary to apply the translation transformation to each vertex in order to obtain the translated polygon.