Professional Documents
Culture Documents
30/01/2024 2
Contents
Pentagon
30/01/2024 4
Polygon Representation
For objects described by many polygons with many vertices, this can
be a time consuming process.
One method for reducing the computational time is to represent
the polygon by the (absolute) location of its first vertex, and
represent subsequent vertices as relative positions from the previous
vertex. This enables us to translate the polygon simply by changing
the coordinates of the first vertex.
30/01/2024 5
Examples of Polygon
A C A A A
A F C
B C D
B E
B C D E C D B F
B D
Arbitrary Shape
Triangle Rectangle Pentagon Hexagon
Polygon
30/01/2024 6
Different ways of Polygon Filling
Types of filling
• Solid-fill: All the pixels inside the polygon’s boundary are illuminated.
Polygon Filling
Algorithm
30/01/2024 9
Inside-Outside Tests
Area filling algorithms and other graphics processes often need to identify
interior regions of objects. There are two types of polygon
A
D
C
G E
F
B
C .P A C .P G E
G E
1
1
F
F
B
B
Number of edges C
.P
intersected by line is G E
N = 0 +1 =1 1
N = 1 + (-1) = 0 F
B
The final value of N is 0
Polygon with self intersections
Fig. 3.33 (d) Working Nonzero winding number
Scan Line Y
B
The scan-line polygon-filling algorithm
involves
• the horizontal scanning of the polygon E
from its lowermost to its topmost vertex, D
• identifying which edges intersect the Fig. 3.34 Interior pixels along a scan line passing through a
8
• and finally drawing the interior 7
horizontal lines with the specified fill color 6
Scan Line Y
5
process. 4
3
2
1
1 2 3 4 5 6 7 8 9
30/01/2024 Fig. 3.35 Horizontal Scanning
16
The Scan-Line Polygon Fill Algorithm
(Procedure) A
C
1. Locate the x-intersection points of the scan
line with the polygon edges.
Scan Line Y
For scan-line Y=8, the x-intersection B
points are x=2, x=6, x=12 and x=15
2. Sort these intersection points from left to
E
right. D
(2, 8), (6, 8), (12, 8) and (15,8)
3. Paint the corresponding frame-buffer (2, 8) (6, 8) (12, 8) (15, 8)
So we need to paint all pixels between end polygon area representing edge intersections
30/01/2024 18