3. What is a Convex Polygon?
• A polygon P is called convex if x in P and y in P implies that
the segment xy is a subset of P.
• A vertex is called reflex if its internal angle is greater than π.
• Any polygon with a reflex vertex is not convex.
3
4. Convex Hull of a Planer Set of Points
• The convex hull of a set of points is the shape taken by a
rubber band stretched around nails pounded into the plane at
each point.
4
5. Convex Layers of a Planer Set of Points
• Let S be the set of points.
• The set of convex layers is derived by applying following
procedure iteratively on S: compute the convex hull of S and
remove its vertices from S.
5
6. Research Problem
• A set of points where points may be inserted or deleted is
called a dynamic set of points.
• A practical algorithm to maintain convex layers of a dynamic
set of points is not available in literature.
6
11. Related Research Paper
K. R. Wijeweera, S. R. Kodituwakku (2018), On the Convex
Layers of a Planer Dynamic Set of Points, Ceylon Journal of
Science, Volume 47 (Issue 2), pp. 165-174.
11
12. Representation of a Layer
• Each convex layer can be represented by a convex polygon.
• The layers are numbered beginning from 0.
• The very first point which arrives should always belong to
the 0th layer.
12
13. Representation of a Layer…
• A layer is represented as a set of edges.
• Edges are also numbered beginning from 0s in each layer.
• Figure shows the representation of jth edge in ith layer.
13
14. Representation of a Layer…
• A layer or an edge can have two states: dead or alive.
• Only alive layers and alive edges are considered as the
convex layers.
• These two states are stored in array elements l_dead[i] and
e_dead[i][j].
• l_dead[i] = 1 ith layer is dead All the edges of the ith
layer are dead.
• e_dead[i][j] = 1 jth edge of the ith layer is dead.
14
16. Construction of the Primary Hull
• Each layer begins with a single point and later it may evolve
to a convex polygon.
• When a layer is a triangle then it is called “primary hull”.
• The very first point should be included to the 0th layer by
setting it as (sx[0][0], sy[0][0]).
• If next point coincides with the very first point then it should
be set as (sx[1][0], sy[1][0]).
• If next point also coincides with the very first point then it
should be set as (sx[2][0], sy[2][0]).
• In this way, coincident points are propagated to inner layers.
16
17. Construction of the Primary Hull…
• The point which is distinct to the very first point for the first
time is set as (ex[0][0], ey[0][0]).
• After insertion of the first edge to the 0th layer then the next
point can have two states: collinear with 0th edge or not.
17
18. Construction of the Primary Hull…
• The vertices of the triangle: P1 (x1, y1), P2 (x2, y2), P3 (x3, y3).
• Let txy = x1 * (y2 – y3) + x2 * (y3 – y1) + x3 * (y1 – y2).
• txy = 0 ↔ (P1, P2, P3) are collinear.
• txy > 0 ↔ (P1, P2, P3) are in anticlockwise order.
• txy < 0 ↔ (P1, P2, P3) are in clockwise order.
18
txy > 0 txy < 0
19. Collinear with the 0th Edge
• If next point is collinear with the 0th edge then there are three
possibilities as shown in the figure.
• In first two situations, the closest end point should be
replaced by the new point. The dropped end point should be
transferred to the closest inner layer.
• There is no extension for the third situation. The new point
should be transferred to the closest inner layer.
19
20. Non Collinear with the 0th Edge
• If next point is not collinear with the 0th edge then the convex
layer should be extended to a triangle.
• Let coordinates of the new point be (x, y).
• Two new edges should be added to the layer h to extend.
• 1st edge: sx[h][1] = x; sy[h][1] = y; ex[h][1] = sx[h][0];
ey[h][1] = sy[h][0];
• 2nd edge: sx[h][2] = x; sy[h][2] = y; ex[h][2] = ex[h][0];
ey[h][2] = ey[h][0];
20
21. Construction of the Secondary Hull
• The mechanism used to extend convex layer differs after the
layer became a triangle.
• Let (xc/3, yc/3) be the centroid of the primary hull.
• xc = sx[h][0] + ex[h][0] + sx[h][1]; yc = sy[h][0] + ey[h][0] +
sy[h][1];
• (xc/3, yc/3) always remains inside the layer even though the
layer is extended.
• If (xc/3, yc/3) and the new point are in opposite sides of a
given edge of the convex layer then it is said that the new
point is OUTSIDE to that edge.
21
22. Identifying INSIDE or OUTSIDE to an Edge
• The vertices of the triangle: P1 (x1, y1), P2 (x2, y2), P3 (x3, y3).
• Let txy = x1 * (y2 – y3) + x2 * (y3 – y1) + x3 * (y1 – y2).
• txy = 0 ↔ (P1, P2, P3) are collinear.
• txy > 0 ↔ (P1, P2, P3) are in anticlockwise order.
• txy < 0 ↔ (P1, P2, P3) are in clockwise order.
22
txy > 0 txy < 0
23. Identifying INSIDE or OUTSIDE to an Edge…
• Let N be the new point and G be the centroid of the primary
hull.
• Note that N is INSIDE all the edges of the layer except edge
AB.
• txy {B, A, N} * txy {B, A, G} < 0 N is OUTSIDE AB.
• txy {B, A, N} * txy {B, A, G} ≥ 0 N is INSIDE AB.
23
24. Expansion of a Layer
• When a new point appears, the outermost convex layer to
which that point is outside should be selected first.
• If the new point is not outside any of the convex layers
available then new layer should be created inside the
innermost layer.
24
25. Expansion of a Layer…
• When a layer expands then it may leave some of its existing
points.
• These points should be transferred to the adjacent inner layer
of the current layer as new points.
• This procedure should be carried out inheriting points from
outer layers to inner layers.
25
31. How to Expand a Layer
• Suppose new point appears outside a single edge of the layer.
• The edge AB should be set into dead.
• Two alive edges AN and BN should be added to the layer.
31
32. How to Expand a Layer…
• Suppose new point appears outside two edges of the layer.
• Edges MP and MQ are added as alive edges to the layer.
• Edges MQ and MR are added as alive edges to the layer.
• Note that the edge MQ appears twice in the list of edges.
32
33. How to Expand a Layer…
• If an edge appears more than once in the list of edges then it
should be set into dead.
• Therefore, the edge MQ should be set into dead.
• The point Q should be transferred to adjacent inner layer.
33
38. Analysis of the Algorithm
• Suppose that there are n points on the plane.
• The convex layers have already been found and suppose that
there are k convex layers.
• Then each layer contains (n/k) average number of points.
• Three cases:
• Insertion of a point.
• Deletion of a point.
• Working in the dynamic context.
38
39. Insertion of a Point
• The worst case occurs when the new point appears outside all
the layers.
• Suppose a point is transferred to a layer.
• It takes O (n/k) time to search and set dead the existing edges
of a layer.
• It takes O [(n/k)2] time to detect duplicate edges in the edge
list.
• Altogether, it takes O (n/k) + O [(n/k)2] = O [(n/k)2] time to
transfer a single point to a layer.
• A layer receives O (n/k) points in the worst case.
• Therefore, it takes O [(n/k)2] * O (n/k) = O [(n/k)3] time to
transfer points between two adjacent layers.
• Since there are k layers, it takes O [(n/k)3] * O (k) = O (n3/k2)
time to insert a point in the worst case. 39
40. Deletion of a Point
• The worst case occurs when a point on the outermost layer is
deleted.
• All the points except the point to be deleted should be
transferred to inner layers.
• Thus the deletion problem becomes an insertion problem.
• Therefore, it takes O (n3/k2) time to delete a point in the worst
case.
40
41. Working in the Dynamic Context
• A single point can be inserted or deleted in O (n3/k2) time.
• Therefore, the algorithm takes n * O (n3/k2) = O (n4/k2) time
to compute the convex layers in the dynamic context.
41
42. Drawbacks of Sanjib & Niraj Algorithm
• The algorithm assumes that the set of points does not contain
any collinear points.
• The authors proposed a theoretical algorithm without
providing a corresponding implementation.
• The notion of tangent is not available in higher dimensions.
42
44. Conclusions
• The proposed algorithm takes O (n3/k2) time to perform an
insertion or a deletion of a point whereas Sanjib & Niraj
algorithm takes O (n) time.
• The proposed algorithm takes O (n4/k2) time in dynamic
context whereas Sanjib and Niraj algorithm takes O (n2) time.
• The proposed algorithm can handle set of points with
coincident points and collinear points.
• The proposed algorithm was successfully implemented using
C programming language.
• The notion used in the proposed algorithm can be extended
into higher dimensions.
44