## Figures

## Abstract

To construct a simple polygon from a set of plane points, we propose an iterative inserting ordered points (IIOP) algorithm. Using a given a set of ordered non-collinear points, a simple polygon can be formed and its shape is dependent on the sorting method used. To form such simple polygons with a given set of plane points, the points must first be ordered in one direction (typically, the *x*-axis is used). The first three points in the set are used to form an initial polygon. Based on the formed polygon, new polygons can be iteratively formed by inserting the first point of from among the remaining set of points, depending on line visibility from that point. This process is carried out until all the points are inserted into the polygon. In this study, we generated 20, 50, and 80 plane points and used the proposed method to construct polygons. Experimental results show that these three polygons are all simple polygons. Through theoretical and experimental verification, we can concluded that when given a set of non-collinear points, a simple polygon can be formed.

**Citation: **Zhang H, Zhao Q, Li Y (2020) Generation of simple polygons from ordered points using an iterative insertion algorithm. PLoS ONE 15(3):
e0230342.
https://doi.org/10.1371/journal.pone.0230342

**Editor: **Hector Vazquez-Leal, Universidad Veracruzana, MEXICO

**Received: **December 24, 2019; **Accepted: **February 26, 2020; **Published: ** March 13, 2020

**Copyright: ** © 2020 Zhang et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.

**Data Availability: **All relevant data are within the manuscript.

**Funding: **This work was supported by Young Scientists Fund of National Natural Science Foundation of China (No.41301479); University Innovation Talent Support Program of Liaoning Province (No.LR2016061); General Project of Science, and Technology Research of Education Department of Liaoning Province (No. LJCL009); and the grant recipient of all the funds are Quanhua Zhao. Quanhua Zhao provides the main idea of the research and responsible for the revision of the manuscript.

**Competing interests: ** The authors have declared that no competing interests exist.

## Introduction

Constructing a simple polygon from a set of plane points is an important process in computational geometry [1] as simple polygons are widely used in computer graphics, image processing, entity construction, and other fields [2–4]. However, the fundamental problem of constructing simple polygons from a set of discrete points is still under investigation.

Currently, several methods are being used to construct a simple polygons from a set of discrete points, such as the polar coordinate sorting [5], dichotomy sorting [6], convex-hull construction [7], and visual region [8] methods. In the dichotomy sorting method [5], two outer points are determined from the maximum and minimum values of *x*-axis (or *y*-axis) projection. The line connecting the two points can divide the set of points into two subsets. The points in these two subsets are sorted according to the value of *x*-axis (or *y*-axis) projection and sequentially connected to form a polygon. In the polar coordinate sorting method [6], a point is randomly selected from a given set as the origin of the polar coordinate system. Afterward, the angles of all the vectors formed by the origin and other points are calculated, and all the points are ordered according to the included angles. The sorted points are then sequentially connected to form a polygon. In the convex-hull construction method [7], a convex hull is first constructed from a given set of points. Here, iteration is started with the convex hull as the initial polygon. In each iteration, a point is randomly selected from the remaining set of points and inserted into the original polygon to form a new polygon. Finally, in the triangle-based construction method [8], an initial triangle is constructed from three randomly selected points and is considered as the initial polygon. The iterative process entails the gradual insertion of the remaining points in the polygon. Although the methods listed above have yielded good experimental results in the process of polygon construction some problems remain. For instance, during polygon construction, invalid points may be encountered. Additionally, it is impossible to prove that a simple polygon can be formed using a given set of discrete points. To solve these problems, in this study, we developed an iterative inserting ordered points (IIOP) algorithm and verified its feasibility of this algorithm theoretically and experimentally. We demonstrate that a simple polygon can be formed using a set of discrete points in which all the points are considered as polygon nodes.

The rest of this article is organized as follows. After defining some functions used in the polygon construction algorithm in the next section, we describe the process of polygon construction and theoretically demonstrate its feasibility. Later, we shall discuss several experimental results and finally present our main conclusions.

## Preliminary definitions

### Simple polygon

Consider a set of *n* points. These points can act as the nodes of a polygon ** G**, if

**satisfies the following conditions.**

*G*- A node connects only two lines.
- Arbitrary non-adjacent lines do not intersect with each other.
- There is no loop in the closed geometry.

Under such conditions, ** G** can be defined as a simple polygon [9].

Fig 1 show a polygon ** G** with a set of 7 nodes: this node set can be denoted as

**= {**

*v**v*

_{1},

*v*

_{2},

*v*

_{3},

*v*

_{4},

*v*

_{5},

*v*

_{6},

*v*

_{7}}. In Fig 1(A)–1(D), each polygon has a different geometry and the polygons in Fig 1(A)–1(C) are not simple. In Fig 1(A), point

*v*4 connects four lines (

*v*

_{1}

*v*

_{4},

*v*

_{3}

*v*

_{4},

*v*

_{4}

*v*

_{6}, and

*v*

_{4}

*v*

_{7}) and hence does not satisfy Condition 1. In Fig 1(B), lines

*v*

_{1}

*v*

_{6}and

*v*

_{4}

*v*

_{5}intersect, thus nullifying Condition 2. Meanwhile, Fig 1(C) does not satisfy Condition 3. However, because the polygon in Fig 1(D) satisfies all the conditions listed above, it can be classified as a simple polygon.

(a)-(d) Polygons with different geometries.

### Visibility of a polygon line from a point

Given a polygon and a point outside of the polygon, if a node of the polygon is visible from the point, then a line formed between the node and point does not cross any other polygon line. If and only if a polygon line is visible for the point, the two endpoints of this line are visible for the point [10–12].

Fig 2 shows a polygon ** G** (Δ

*v*

_{1}

*v*

_{2}

*v*

_{3}) and a point

*v*

_{i}outside it. When the point

*v*

_{i}and node

*v*

_{2}are connected we can see that the new line

*v*

_{i}

*v*

_{2}does not intersect with any other line of the polygon

**and similar is the case with line**

*G**v*

_{i}

*v*

_{3}. Thus, we can infer that line

*v*

_{2}

*v*

_{3}is visible from point

*v*

_{i}. When point

*v*

_{i}is connected with node

*v*

_{1}, the new line

*v*

_{i}

*v*

_{1}intersects with line

*v*

_{2}

*v*

_{3}. Therefore, lines

*v*

_{1}

*v*

_{2}and

*v*

_{1}

*v*

_{3}are invisible from point

*v*

_{i}.

### Line-to-line occlusion at a given point

Assume that there are two lines (*v*_{1}*v*_{2} and *v*_{3}*v*_{4}) and one point (*v*_{i}). The two lines do not intersect (or only intersect at the endpoints). With respect to point *v*_{i}, line *v*_{1}*v*_{2} occludes line *v*_{3}*v*_{4} if and only if the following conditions are satisfied.

- There is a ray
*t*starting at point*v*_{i}and it intersects with both lines*v*_{1}*v*_{2}and*v*_{3}*v*_{4}, at different points. - If the intersections of ray
*t*with lines*v*_{1}*v*_{2}and*v*_{3}*v*_{4}are*s*_{i}and*s*_{j}(*i ≠ j*), respectively, then*d*(*v*_{i},*s*_{i}) <*d*(*v*_{i},*s*_{j}) [13–14].

Fig 3(A) shows two disjoint lines *v*_{1}*v*_{2} and *v*_{3}*v*_{4}. A ray *t* starts at point *v*_{i} and intersects with lines *v*_{1}*v*_{2} and *v*_{3}*v*_{4} at points *s*_{i} and *s*_{j}, respectively, and thus, it satisfies Condition 1. Additionally, we can see that *d*(*v*_{i}, *s*_{i})<*d*(*v*_{i}, *s*_{j}), which satisfies Condition 2; hence, it can be inferred that line *v*_{1}*v*_{2} occludes *v*_{3}*v*_{4} at point *v*_{i}. Fig 3(B) shows two lines with intersecting endpoints: here, points *v*_{2} and *v*_{4} represent the same point. Moreover, ray *t* intersects lines *v*_{1}*v*_{2} and *v*_{3}*v*_{4} at points *s*_{i} and *s*_{j} (*i ≠ j*), respectively, and *d*(*v*_{i}, *s*_{i}) < *d*(*v*_{i}, *s*_{j}). Therefore, line *v*_{1}*v*_{2} occludes *v*_{3}*v*_{4} at point *v*_{i}. Fig 3(C) shows two disjoint lines *v*_{1}*v*_{2} and *v*_{3}*v*_{4}. There is no ray starting at point *v*_{i} that can intersect lines *v*_{1}*v*_{2} and *v*_{3}*v*_{4} simultaneously. Hence, it does not satisfy Condition 1 and there is no occlusion. Fig 3(D) shows two lines with intersecting endpoints. Although there is a ray starting at point *v*_{i} that can simultaneously intersect lines *v*_{1}*v*_{2} and *v*_{3}*v*_{4}, intersection occurs at the same point. Therefore, Condition 1 is not satisfied and there is no occlusion.

(a) Occlusion with no intersection, (b) occlusion with intersection, (c) no intersection & no occlusion, and (d) no occlusion with intersection.

### Generation of a simple polygon

Consider a set of ordered points ** v** = {

*v*

_{i}(

*x*

_{i},

*y*

_{i});

*i*= 1, …,

*n*}, in which no two points are coincident and no three points are collinear. In this point set,

*i*is the index of points,

*v*

_{i}is used to indicate the point

*i*,

*n*is the number of points in the set (usually

*n*> 3), and (

*x*

_{i},

*y*

_{i})⊰

*R*^{2}represent the coordinates of point

*i*. For

*v*

_{i}and

*v*

_{i+1}(

*i*= 1, . . . .,

*n*—1), if the

*x*coordinates are the same

*x*

_{i+1}=

*x*

_{i}, then

*x*

_{i+1}=

*x*

_{i}; ohterwise

*x*

_{i+1}>

*x*

_{i}.

Usually, we regard *x*-axis as the horizontal axis, *y*-axis as the vertical axis perpendicular to the *x*-axis, and the intersection of the two axes as origin *o* (Fig 4). There are five ordered points in this figure And their set can be represented as ** v** = {

*v*

_{1},

*v*

_{2},

*v*

_{3},

*v*

_{4},

*v*

_{5}}. After sorting,

*x*

_{1}≥

*x*

_{2}≥

*x*

_{3}≥

*x*

_{4}≥

*x*

_{5.}Moreover, when

*x*

_{1}=

*x*

_{2},

*y*

_{2}>

*y*

_{1}. Because the

*x*-coordinates of all the points are different, their

*y*-coordinates were not considered when ordering.

### Polygon-generation process

(1) Initialization. From a given set of ordered points ** v** = {

*v*

_{i},

*i*= 1, …,

*n*}, we select the first

*nc*

^{(0)}points (usually 3) to construct a polygon

*v*_{c}

^{(0)}(note that

*v*_{c}represents both the polygon and the set of points that compose it). The set of points corresponding to this polygon can be denoted as

*v*_{c}

^{(0)}= {

*v*

_{ck}

^{(0)},

*k*= 1, …,

*nc*

^{(0)}}, where

*nc*

^{(0)}is the point number of the constructed polygon. The residual points in set

**are included in the remaining set**

*v*

*v*_{s}

^{(0)}= {

**/**

*v*

*v*_{c}

^{(0)}} = {

*v*

_{sl}

^{(0)},

*l*= 1, …,

*n–nc*

^{(0)}}; set

*v*_{s}is still a set of ordered points and the sorting method is consistent with that of set

**.**

*v*Fig 5 shows an example of polygon initialization. There are 5 ordered points in the set, i.e., ** v** = {

*v*

_{1},

*v*

_{2},

*v*

_{3},

*v*

_{4},

*v*

_{5}} = {

*v*

_{i},

*i*= 1, …,

*n*}, where

*n*= 5. Select the first

*nc*

^{(0)}points to construct a polygon

*v*_{c}

^{(0)}. Set

*v*_{c}

^{(0)}= {

*v*

_{1}/

*v*

_{c1}

^{(0)},

*v*

_{2}/

*v*

_{c2}

^{(0)},

*v*

_{3}/

*v*

_{c3}

^{(0)}} = {

*v*

_{ck}

^{(0)},

*k*= 1, …,

*nc*

^{(0)}}, where

*nc*

^{(0)}= 3 and the symbol / denotes the same point. In the remaining set,

*v*_{s}

^{(0)}= {

**/**

*v*

*v*_{c}

^{(0)}} = {

*v*

_{4}/

*v*

_{s1}

^{(0)},

*v*

_{5}/

*v*

_{s2}

^{(0)}}.

(a) Random point distribution and (b) polygon initialization.

(2) Let *τ* be the iteration indicator. Considering point *v*_{s1}^{(τ)} in the remaining set *v*_{s}^{(τ)} as an insertion point, we can conclude that the point before point *v*_{s1}^{(τ)} is *v*_{nc}^{(τ)} in the set ** v**. We find two lines which connect point

*v*

_{nc}

^{τ)}from the polygon

*v*_{c}

^{(τ)}and judging the visibility of these two lines from point

*v*

_{s1}

^{(τ)}. Then insert point into the line which is visible from it. If both lines are visible from point

*v*

_{s1}

^{(τ)}, one line is selected randomly. The set of points of the new polygon can be rewritten as

*v*_{c}

^{(τ + 1)}= {

*v*

_{ck}

^{(τ + 1)},

*k*= 1, 2, …,

*n*

_{c}

^{(τ + 1)}},

*nc*

^{(τ + 1)}=

*nc*

^{(τ)}+ 1, and the iteration indicator is

*τ*=

*τ*+ 1.

Polygon *v*_{c}^{(0)} is considered as the initial polygon, and the iteration process is started. As shown in Fig 5(B), by judging the visibility of the two lines at *v*_{nc}^{(τ)} = *v*_{3}/*v*_{c3}^{(0)} and *v*_{s1}^{(τ)} = *v*_{4}/*v*_{s1}^{(0)}, both *v*_{1}*v*_{3} and *v*_{2}*v*_{3} are visible from point *v*_{s1}^{(τ)}. Therefor, one line is selected randomly and the point *v*_{s1}^{(τ)} is inserted into it; if we select line *v*_{1}*v*_{3}, the resulting polygon is as shown in Fig 6(A). Consider the set of points *v*_{c}^{(1)} = {*v*_{1}/*v*_{c1}^{(1)}, *v*_{2}/*v*_{c2}^{(1)}, *v*_{3}/*v*_{c3}^{(1)}, *v*_{4}/*v*_{c4}^{(1)}} = {*v*_{ck}^{(1)}, *k* = 1, …, *nc*^{(1)}}, where *nc*^{(1)} = 4 and the remaining set *v*_{s}^{(1)} = {** v**/

*v*_{c}

^{(1)}} = {

*v*

_{5}/

*v*

_{s2}

^{(1)}}. If line

*v*

_{2}

*v*

_{3}is selected, the resulting polygon is as shown in Fig 6(B). Here,

*v*_{c}

^{(1)}= {

*v*

_{1}/

*v*

_{c1}

^{(1)},

*v*

_{2}/

*v*

_{c2}

^{(1)},

*v*

_{4}/

*v*

_{c3}

^{(1)},

*v*

_{3}/

*v*

_{c4}

^{(1)}} and

*v*_{s}

^{(1)}= {

**/**

*v*

*v*_{c}

^{(1)}} = {

*v*

_{5}/

*v*

_{s2}

^{(1)}}. Evidently, the insertion method affects the order of the set

*v*_{c}and polygon geometry. However, it has no impact on the order of the sets

**and**

*v*

*v*_{s}.

**Lemma 1** The point before point *v*_{s1} is *v*_{nc}. In the case of two lines *r*_{1} and *r*_{2} on which *v*_{nc} is located, at least one line is visible from *v*_{s1}.

** Proof:** Assume that the two lines

*r*

_{1}and

*r*

_{2}are not visible from

*v*

_{s1}. If line

*r*

_{1}is not visible from

*v*

_{s1}, line

*r*

_{2}occludes

*r*

_{1}. A ray

*t*starting from point

*v*

_{s1}intersects lines

*r*

_{1}and

*r*

_{2}at points

*s*

_{m}and

*s*

_{n}, respectively. According to the definition of occlusion,

*d*(

*s*

_{m},

*v*

_{s1}) >

*d*(

*s*

_{n},

*v*

_{s1}). If line

*r*

_{2}is not visible from

*v*

_{s1}, then

*r*

_{1}occludes

*r*

_{2}. When ray

*t*starts at point

*v*

_{s1}, it intersects lines

*r*

_{1}and

*r*

_{2}at points

*s*

_{m}and

*s*

_{n}, respectively. According to the definition of occlusion,

*d*(

*s*

_{n},

*v*

_{s1}) >

*d*(

*s*

_{m},

*v*

_{s1}). Contrary to the assumptions, there is no situation in which both lines

*r*

_{1}and

*r*

_{2}are not visible from the point

*v*

_{s1}. Therefore, it can be demonstrated that at least one line, i.e., either

*r*

_{1}or

*r*

_{2}or both, is visible from point

*v*

_{s1}.

Fig 7 illustrates Lemma 1. As shown in Fig 7(A), the point before point *v*_{s1} is *v*_{nc}. A line passing through *v*_{nc} that is perpendicular to the *x-*axis divides the plane into L and R regions. According to the order of the points, point *v*_{s1} is in the R region. The ray *t* starting at point *v*_{s1} intersects lines *r*_{1} and *r*_{2} at points *s*_{m} and *s*_{n}, respectively. If *d*(*s*_{m}, *v*_{s1}) > *d*(*s*_{n}, *v*_{s1}), *r*_{1} is not visible from *v*_{s1}; similarly, if *d*(*s*_{n}, *v*_{s1}) > *d*(*s*_{m}, *v*_{s1}), *r*_{2} is not visible from *v*_{s1.} If there is no ray *t* that can simultaneously intersect lines *r*_{1} and *r*_{2} (except line *v*_{s1}*v*_{nc}, as shown in Fig 3(D)), both lines are visible from *v*_{s1}.

(a) Visibility example and (b) visibility from different regions.

Lemma 1 indicates that either *r*_{1} or *r*_{2} or both lines are visible from point *v*_{s1}. As shown in Fig 7(B), region R can be divided into three parts by extending lines *r*_{1} and *r*_{2}, i.e., R = {R_{1}, R_{2}, R_{3}}. When point *v*_{s1} is in R_{1}, line *r*_{1} is visible and line *r*_{2} is not visible. When point *v*_{s1} is in R_{3}, line *r*_{2} is visible and line *r*_{1} is not visible from it. When point *v*_{s1} is in R_{2}, both *r*_{1} and *r*_{2} are visible from it.

(3) The final polygon is generated at an iteration indicator *τ* = *n–* 3. At this time, the number of points in the remaining set is 0. The set of points corresponding to the polygon is *v*_{c}^{(n– 3)} = {*v*_{ck}^{(n– 3)}, *k* = 1, …, *n*} = ** v**.

The polygon-generation process is illustrated in Fig 8(A)–8(F). There are seven ordered points that can be denoted as ** v** = {

*v*

_{1},

*v*

_{2},

*v*

_{3},

*v*

_{4},

*v*

_{5},

*v*

_{6},

*v*

_{7}}. The first three points are connected to form an initial polygon

*v*_{c}

^{(0)}= {

*v*

_{c1}

^{(0)},

*v*

_{c2}

^{(0)},

*v*

_{c3}

^{(0)}} and the remaining set of points can be denoted by

*v*_{s}

^{(0)}= {

*v*

_{s1}

^{(0)},

*v*

_{s2}

^{(0)},

*v*

_{s3}

^{(0)},

*v*

_{s4}

^{(0)}}. Consider the first point

*v*

_{s1}

^{(0)}in

*v*_{s}

^{(0)}; the point preceding

*v*

_{s1}

^{(0)}is point

*v*

_{c3}

^{(0)}. Therefore, we need to judge the visibility of lines

*v*

_{c3}

^{(0)}

*v*

_{c2}

^{(0)}and

*v*

_{c3}

^{(0)}

*v*

_{c1}

^{(0)}from

*v*

_{s1}

^{(0)}. The line

*v*

_{c3}

^{(0)}

*v*

_{c2}

^{(0)}is visible from point

*v*

_{s1}

^{(0)}and hence, we insert point

*v*

_{s1}

^{(0)}into the line to form the new polygon

*v*_{c}

^{(1)}= {

*v*

_{c1}

^{(1)},

*v*

_{c2}

^{(1)},

*v*

_{c3}

^{(1)},

*v*

_{c4}

^{(1)}} and the remaining set of points can be written as

*v*_{s}

^{(1)}= {

*v*

_{s1}

^{(1)},

*v*

_{s2}

^{(1)},

*v*

_{s3}

^{(1)}}, as shown in Fig 8(C). After the iterative insertion process is completed, the final polygon shown in Fig 8(F) is obtained.

(a) Random point distribution, (b) polygon initialization, (c) result of one iteration, (d) result of two iterations, (e) result of three iterations, and (f) final polygon.

### Polygon-generation algorithm

Given a set of ordered points ** v**, the steps required to generate a polygon can be represented using the following pseudo-codes.

Initialization: Initial polygon *v*_{c} and *v*_{s} is the set of remaining points

For *τ* = 0 to *n–* 3

- The number of nodes in polygon
*v*_{c}^{(τ)}is denoted as*nc*^{(τ)}. - Find two sides of point
*v*_{nc}^{(τ)}from polygon*v*_{c}^{(τ)}and denote them as*r*_{1}and*r*_{2}. - Select the first node
*v*_{s1}^{(τ)}from*v*_{s}^{(τ)}. - Judge the visibility of
*r*_{1}and*r*_{2}from*v*_{s1}^{(τ)}. - Insert
*v*_{s1}^{(τ)}into*r*_{1}or*r*_{2}, whichever line is visible from it. - Generate polygon
=*G**v*_{c}^{(τ +1)}.

End

- Generate polygon
=*G**v*_{c}

## Experiments and results

This study proposes a simple polygon-construction method, which proves that in a given set of points, all points can be regarded as polygon nodes and can form a simple polygon. In the current experimental section, the number of simple polygons generated is counted and the criterion of whether all given points can be used as polygon nodes to form simple polygons is used to evaluate the proposed algorithm.

### Relationship between the number of polygons and the number of points

From **Lemma 1** it can be seen that a simple polygon can be formed from a set of points. Additionally, the number of polygons generated is not unique according to the constructing method. From a set of ordered points ** v** = {

*v*

_{i}(

*x*

_{i},

*y*

_{i});

*i*= 1, …,

*n*}. Evidently, the first three points

*v*

_{1},

*v*

_{2}, and

*v*

_{3}can be used to construct one polygon. Based on our proposed method, point

*v*

_{4}is inserted into the polygon generated by the first three points, i.e., point

*v*

_{4}is inserted on either line

*v*

_{1}

*v*

_{3}or line

*v*

_{2}

*v*

_{3}. Therefore, when both lines are visible from point

*v*

_{4}, two polygons can be formed which implies that a maximum of two polygons can be formed. In the two polygons formed from the four points described above, when point

*v*

_{5}is inserted, each polygon yields two new polygons. Therefore, a maximum of four polygons can be formed from five points. By analogy, according to the given method, a maximum of 2

^{n – 3}polygons can be constructed from a set of

*n*non-collinear points.

As shown in Fig 9(A), from a set of five ordered points ** v** = {

*v*

_{1},

*v*

_{2},

*v*

_{3},

*v*

_{4},

*v*

_{5}}, the first three points

*v*

_{1},

*v*

_{2}, and

*v*

_{3}are selected to construct a triangle Δ

*v*

_{1}

*v*

_{2}

*v*

_{3}. subsequently, point

*v*

_{4}is inserted into the triangle formed by the first three points. Because the points follow a particular order, point

*v*

_{4}can exist only in the R region, which is divided into three parts denoted as R = {R

_{1}, R

_{2}, R

_{3}}. When point

*v*

_{4}is present in R

_{1}or R

_{3}, only one of the two lines containing point

*v*

_{3}is visible from it. Therefore, only one polygon can be constructed. When point

*v*

_{4}is in R

_{2}, both lines containing

*v*

_{3}are visible from it, and hence, it can form two polygons. According to the proposed polygon-construction method, a maximum of two polygons can be constructed using four points (Fig 9(B)). Similarly, when point

*v*

_{5}is inserted four polygons can be constructed (Fig 9(C)).

(a) Generation of the initial polygon, (b) polygon constructed from 4 points, (c) polygon constructed from 5 points.

### Relationship between polygon shape and point order

In this section, we shall discuss the relationship between the number of points and the number of polygons that can be constructed with the same coordinate order. The influence of different coordinate axis directions on polygon shape when the relative position of a group of points is unchanged is also considered.

As shown in Fig 10, given a set of points ** v** = {

*v*

_{i},

*i*= 1, …, 8}, the positional relationship between the points remains unchanged. Fig 10(A)–10(C) depict the polygons formed when the

*x*-axis direction is horizontal, rotated by 45º to the left, and rotated by 90º to the left, respectively. Note that when the

*x*-axis is in different directions, the order between the points as well as the shape of the polygon are different. Therefore, it can be concluded that the shape of the polygon depends on the arrangement of points, which in turn is dependent on the direction of the coordinate axis. However, according to the theoretical proof, given a set of non-collinear points, a simple polygon can be formed regardless of the direction of the coordinates.

(a) Horizontal *x*- axis, (b) *x*- axis rotated by 45º to the left, and (c) vertical *x*-axis.

### Polygon generation experiment

To verify the feasibility of the proposed method, 20, 50, and 80 points were randomly generated and a simple polygon was then generated from each of these sets using the proposed algorithm. Fig 11 shows the plane distribution of 20, 50, and 80 random points. The experimental results are shown in Fig 12. As described in the section on the relationship between number of polygons and number of points, the number of simple polygons generated by the proposed algorithm is not unique. Fig 12 shows two different geometric polygons formed by each group of points. Fig 12(A1)–12(A2), 12(B1)–12(B2) and 12(C1)–12(C2) represent polygons consisting of 20, 50, and 80 points, respectively, and it can be noticed that all the constructed polygons are simple polygons.

Plane distribution of (a) 20, (b) 50, and (c) 80 random points.

Polygons consisting of (a1)-(a2) 20, (b1)-(b2) 50, and (c1)-(c2) 80 points.

Some regions of the polygon with 80 random points cannot be seen clearly. We considered the polygon generated in Fig 12(C1) as an example and enlarged a part of its area (Fig 13). Figs 13(B)–13(D) represent enlarged images of areas in the blue, green, and black boxes in Fig 13 (A), respectively. We can see that the polygon with 80 random points is still a simple polygon. Moreover, the points in the graph are randomly generated, which verifies the feasibility of the proposed method for constructing simple polygons.

(a) Polygon consisting of 80 points, (b) enlarged area corresponding to the blue box, (c) enlarged area corresponding to the green box, and (d) enlarged area corresponding to the black area.

### Comparative experiments

Because both the polar coordinate sorting [5] and dichotomy sorting [6] methods can construct simple polygons using all the given random points as polygon nodes, we compared our proposed method with these two methods for generating simple polygons from three groups of different number of random points (see Fig 11). Fig 14 shows the result obtained using the polar coordinate sorting method, where the black dot represents pole position. According to this algorithm, for a set of random points at a given position, this method can only generate a simple polygon with a fixed geometry. Fig 15 shows the result obtained using the dichotomy sorting method. It can be seen that the number of polygons generated is unique when the direction of a given dichotomy is fixed. However, the proposed method can still construct polygons with different geometric shapes when the coordinate axis direction is given, which implies that the approach proposed in this study is more flexible.

Polygon consisting of (a) 20 (b) 50, and (c) 80 points.

Polygon consisting of (a) 20 (b) 50, and (c) 80 points.

Table 1 shows the time required by the three methods to generate polygons for different random points; it can be inferred that the polar coordinate sorting method is the fastest, while the proposed method is the slowest. However, this slow rate can be attributed to its ability to generate polygons of different geometric shapes for which more time is required.

The number of simple polygons constructed by the polar coordinate sorting and dichotomy sorting methods is unique, while the number of simple polygons constructed by the convex-hull construction method [7] is non-unique. However, the latter cannot generate a simple polygon using all the given random points as polygon nodes.

Consider a set of seven ordered points ** v** = {

*v*

_{1},

*v*

_{2},

*v*

_{3},

*v*

_{4},

*v*

_{5},

*v*

_{6},

*v*

_{7}}, as shown in Fig 16(A). The polygon-construction process using the proposed method is shown in Fig 16(B)–16(E) and Fig 16(F) shows the final polygon, which is a simple polygon.

(a) Random point distribution, (b) polygon initialization, (c) result of one iteration, (d) result of two iterations, (e) result of three iterations, and (f) the final polygon.

Fig 17 shows the results of polygon generation using the convex-hull construction method. First, the convex hull of a given node set is generated (Fig 17(A)); later, a point is randomly selected from the remaining points and inserted into the line visible from it to form a new polygon. The final polygon is shown in Fig 17(D). However, none of the polygon edges are visible from point *v*_{4}. Therefore, in this situation, point *v*_{4} is called an invalid point. Finally, we can infer that polygon construction based on the convex-hull method includes a strong element of randomness owing to which it is impossible to construct a simple polygon with all the points in a given set. Unlike the method proposed in this study, using which a simple polygon can be constructed from a given set of non-collinear points, in the convex-hull construction method, invalid points may occur.

(a) Polygon initialization, (b) result of one iteration, (c) result of two iterations, and (d) result of three iterations.

## Conclusion

In this study, we designed an IIOP algorithm to generate a simple polygon from a set of ordered points. Through theoretical and experimental verification of this algorithm, the following three conclusions could be drawn. (1) Given a set of non-collinear points, a simple polygon can be formed. (2) The shape of a simple polygon depends on the sorting method used. (3) The number of polygons is related to the number of random points. When the sorting method is fixed, at least 1 or a maximum of 2^{n – 3} simple polygons can be formed, where *n* is the number of non-collinear points in a set.

## References

- 1. Vaclav Skala. Point-in-Convex Polygon and Point-in-Convex Polyhedron Algorithms with O(1) Complexity using Space Subdivision. ICNAAM 2015. AIP Publishing LLC, 2015; 22–28.
- 2.
Martin N, Roman P, Ignaz R. Partitioning graph drawings and triangulated simple polygons into greedily routable regions. Algorithms and Computation (ISAAC'15). Springer Berlin Heidelberg, 2015. https://doi.org/10.1007/978-3-662-48971-054
- 3. Bose P, Kostitsyna I, Langerman S. Self-approaching paths in simple polygons. Computational Geometry, 2019.
- 4. Oh E, De Carufel JL, Ahn HK. The geodesic 2-center problem in a simple polygon. Computational Geometry. 2018; 74: 21–37.
- 5.
Laszlo MJ. Computational geometry and computer graphics in C++. 1st ed. Upper Saddle River, NJ: Prentice Hall, 1996; 109–112. https://doi.org/10.1109/5.163408
- 6. Weixin W, Yongping H. The algorithm of constructing polygons by sorting the scattered points. Journal of Shenyang Ligong University. 1997; 16(4): 11–14. (in Chinese)
- 7.
Muravitskiy V, Tereshchenko V. Generating a simple polygonalizations. In 2011 15th International Conference on Information Visualisation, IEEE. 2011; 668–671. https://doi.org/10.1109/IV.2011.88
- 8.
Dailey D, Whitfield D. Constructing random polygons. In Proceedings of the 9th ACM SIGITE Conference on Information Technology Education. 2008; 119–124. https://doi.org/10.1145/1414558.1414592
- 9. Li F, Klette R. Euclidean shortest paths in a simple polygon. Algorithms, Architectures and Information Systems Security. 2015.
- 10. Cardinal J, Hoffmann U. Recognition and complexity of point visibility graphs. Discrete and Computational Geometry. 2017; 57: 164–178.
- 11. Himmel AS, Hoffmann C, Kunz P, Froese V, Sorge M. Computational complexity aspects of point visibility graphs. Discrete Applied Mathematics. 2019; 254: 283–290.
- 12. Bahoo Y, Banyassady B, Bose P K, Durocher S, Mulzer W. A time–space trade-off for computing the k -visibility region of a point in a polygon. Theoretical Computer Science, 2019; 789: 13–21.
- 13. Chen DZ, Wang H. Visibility and ray shooting queries in polygonal domains. Computational Geometry—Theory and Applications. 2015; 48(2): 31–41.
- 14. Chen DZ, Wang H. Weak visibility queries of line segments in simple polygons. Computational Geometry. 2015; 48(6): 443–452.