Polygons
Polygons
Jayanta Mukhopadhyay
p5 p3
p4
p1
p4
p5 p1
A simple polygon is a planar polygon if the vertices lie on a plane.
A 2-D simple polygon is always a planar polygon.
A planar polygon partitions the plane in two regions, namely, its
interior and exterior.
Euler’s theorem; |V | − |E | + |F | = 2 ⇒ |F | = 2..
The sequence of vertices are described in such an order, so that the
interior of the polygon lies at the left half plane of the direction of
traversal (on an edge).
The reverse order of sequence of vertices denote the exterior region.
Jayanta Mukhopadhyay (CSE, IIT Kharagpur) Polygons 4 / 53
Concave and convex polygons
Convex polygon: A simple polygon for which a line segment between any
arbitrary two points within its interior including boundary edges completely
lie within the polygon.
Check whether the intersecting point lies on both the line segments.
Else it is FALSE.
Needs floating point operation.
Signs: +ve: in the right-half plane, and -ve: in the left-half plane.
For each y -coordinate within the vertical range from the topmost vertex to
the bottommost vertex do the following.
Draw line segments between each pair of odd and even intersections.
Time complexity: O((ymax − ymin ).nlog(n)) for an n-gon.
Can you improve it for a convex polygon?
Output polygon: s1 p1 s2 v3 v4 s3 p2 s4 v7 v8
If the point lies in the LHP of the edge, q ∈ P, else the point outside
the polygon. O(log(n))
Jayanta Mukhopadhyay (CSE, IIT Kharagpur) Polygons 26 / 53
Point inclusion in an angular sector
Narrow down the angular sector containing q from a wide angular sector of
a polygon using the above rule.
Polygon filling:
Angularly and radially sort the vertices about the centroid to get the
star polygon.
O(nlog(n))
Jayanta Mukhopadhyay (CSE, IIT Kharagpur) Polygons 31 / 53
y-Monotone Polygon Formation
Problem statement: Given a set of 2-D points V form a y-monotone
polygon P so that all the points in the set become its vertices.
Compute the top=most and bottom-most points vt ∈ V and vb ∈ V .
Create two lists of points L and R, where L and R contains the points
in the RHP and the LFP of vb vt .
Sort L and R in descending and ascending orders of y − coordinates.
Merge these two sorted lists to form the y -monotone polygon.
O(nlog(n))
Jayanta Mukhopadhyay (CSE, IIT Kharagpur) Polygons 32 / 53
Convex hull of a set of 2-D points
Convex hull (CH): The minimum area convex polygon enclosing the set of
points.
Properties
The vertices of the CH are from the set of 2-D points.
Extreme points (left,right,top and bottom) are vertices of the CH.
The centroid of the point set lies within the CH.
Degenerate case: If all the points are collinear, the CH is a line
segment with its two extreme points.
The convex hull algorithm works for any star or monotone polygon.
Jayanta Mukhopadhyay (CSE, IIT Kharagpur) Polygons 35 / 53
Computation of Convex Hull of a set of 2-D points
Problem statement: Given a set of 2-D points V compute its convex hull.
Graham’s scan (1972)
Form a star polygon Pstar from V .
Apply the algorithm for computing the CH of Pstar .
O(n.log(n))
Jayanta Mukhopadhyay (CSE, IIT Kharagpur) Polygons 36 / 53
Polygon triangulation
Problem statement: Given a simple polygon P, decompose it into a set of
non-overlapping triangles, whose vertices are from the set of vertices of P.
Problem statement: Given a set n 2-D points V in the plane join them by
non-intersecting straight line segments so that every region internal to the
convex hull CH(V ).
No unique solution.
O(n) number of triangulation.
3-D point set lying on a surface triangulated in 2-D though projection
and inverse projection. Useful for polygonal mesh representation.
Can you get lower and upper bounds on the number of triangles?
Overview:
Form a simple polygon from the point set.
Triangulate the simple polygon.
Compute the convex hull.
Triangulate polygons enclosed by an edge of the convex hull and a
chain of edges of the simple polygon in its exterior.
Mostly unique!
If the condition fails flip the edge by choosing the other diagonal of
the quadrilateral ABDC , to replace the pair by △ABD and △DAC .
No edge rechecked.
O(n2 )