2024 CSN523 Lec 9-10
2024 CSN523 Lec 9-10
2
Representation of a Point:
3
Representation of a Polygon:
Main options
1. Array or list
2. Singly or doubly linked list
3. Linear or circular
Arrays
1.Attractive for code clarity
2. Clumsy with insertion and deletion of points.
We sacrifice simplicity to gain ease of deletion.
Use a doubly linked circular list to represent a polygon
4
Representation of a Polygon:
5
Representation of a Polygon:
6
Implementation Issues:
7
Representation of a Polygon:
8
Representation of a Polygon:
9
Area Computation of a Simple Polygon:
Problem
Given a simple polygon P of n vertices, compute
its area.
10
Area Computation of a Simple Polygon:
11
Area Computation of a Simple Polygon:
Ancient Triangles
Modern Triangles
12
Area Computation of a Simple Polygon:
2𝐴 𝑝 𝑥𝑦 𝑦𝑥
.
13
Implementation Issues:
14
Point Inclusion in a Simple Polygon:
Problem
Given a simple polygon P of n points, and a
query point 𝑞 , is 𝑞 ∈ P?
What if P is convex?
Easy in O(n). Takes a little effort
to do it in O(log n). Left as an exercise.
15
Point Inclusion in a Simple Polygon:
16
Planar Subdivisions:
17
Representing Planar Subdivisions:
18
Representing Planar Subdivisions:
19
Representing Planar Subdivisions:
20
Representing Planar Subdivisions:
21
Representing Planar Subdivisions:
We apply a trick/hack/impossibility:
split every edge length-wise(!) into two half-
edges
Every half-edge:
o has exactly one half-edge as its Twin
o is directed opposite to its Twin
o is incident to only one face (left)
22
DCEL:
23
DCEL:
24
DCEL:
25
DCEL:
26
Storing the Polygon as DCEL:
27
Storing the Polygon as DCEL:
28
DCEL:
29
DCEL:
• vertex v
• coordinates
• an incident half-edge Incident Edge(v) = (v, w)
• half edge 𝑒⃗
• 3 edges Twin(𝑒⃗), Next(𝑒⃗), Prev(𝑒⃗)
• vertex Origin(𝑒⃗)
• a face Incident Face(𝑒⃗)
• face f
• a half-edge 𝑒⃗ (f) of its exterior boundary
• a half-edge of each face contained in f; they are
stored in a list L(f)
30
DCEL:
31