Optimal Reliable PointinPolygon Test and Differential Coding Boolean Operations on Polygons
Abstract
:1. Introduction
1.1. The PointinPolygon Test
1.2. Boolean Operations
1.3. The Major Contributors of This Paper
 For the pointinpolygon test, it provides a full theoretical and experimental analysis and presents the serial Algorithm 1, which requires less running time than previous algorithms, can handle all degenerate cases, and can both quickly determine whether a point is inside or outside a polygon and accurately determine the contours of input polygon (see the example in Figure 3b).
 It describes all degenerate cases and provides corresponding solutions to ensure the stability and reliability (see Figure 2). This also creates the prerequisites and basis for our boolean operations algorithm.
 It also presents a novel Algorithm 2 for boolean operations, as shown in Figure 4.
 Our algorithms avoid the division operation and expensive intersection calculations, do not have to sort the vertices clockwise or counterclockwise beforehand, process all edges one by one in any order for an input polygon, are parallelizable because their many operations can be done in parallel, and are applicable to any polygons, including selfintersecting polygons or those with holes nested to any level of depth (see Figure 3).
 A detailed theoretical and experimental analysis of Algorithms 1 and 2, including the proofs of their correctness (see Theorems 1–4), are shown.
 Using geometric probability and Equation (3), it optimizes all algorithms.
2. Related Work
2.1. The PointinPolygon Test
 Rayintersection algorithm
 Sum of angles algorithm
 Winding number algorithms
 Grid algorithm
 Decomposition algorithm
2.2. Boolean Operations
3. The PointinPolygon Test Principle
 ${x}_{i+1}\le {x}_{p}\le {x}_{i}\wedge {y}_{i+1}={y}_{p}={y}_{i}$, P is on $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2a). Thus, P is on $\partial S$.
 ${x}_{i}\le {x}_{p}\le {x}_{i+1}\wedge {y}_{i}={y}_{p}={y}_{i+1}$, P is on $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2b. Thus, P is on $\partial S$.
 $F\left(P\right)>0\wedge {y}_{i}={y}_{p}\wedge {y}_{p}<{y}_{i+1}$, P is on the backleft side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ ( the viewing direction is along the direction of $\overrightarrow{{P}_{i}{P}_{i+1}}$ , which is maintained below. see Figure 2c). Thus, $\overrightarrow{{P}_{i}{P}_{i+1}}$ intersects $\overrightarrow{PQ}$ and we set $k=k+1$.
 $F\left(P\right)<0\wedge {y}_{i}>{y}_{p}\wedge {y}_{p}={y}_{i+1}$, P is on the frontright side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2d). Thus, $\overrightarrow{{P}_{i}{P}_{i+1}}$ intersects $\overrightarrow{PQ}$ and we set $k=k+1$.
 ${y}_{p}={y}_{i}={y}_{i+1}\wedge {x}_{i+1}>{x}_{i}>{x}_{p}$, $\overrightarrow{{P}_{i}{P}_{i+1}}$ and $\overrightarrow{PQ}$ have the same direction, and the edge $\overline{{P}_{i}{P}_{i+1}}$ is shorter than the edge $\overline{PQ}$ (see Figure 2e). Although both overlap each other on $\overline{{P}_{i}{P}_{i+1}}$, we regard them as having no intersection, and k remains unchanged.
 ${y}_{p}={y}_{i}={y}_{i+1}\wedge {x}_{i}>{x}_{i+1}>{x}_{p}$, $\overrightarrow{{P}_{i}{P}_{i+1}}$ overlaps $\overrightarrow{PQ}$ , and both have opposite directions (see Figure 2f). Although both overlap on $\overrightarrow{{P}_{i}{P}_{i+1}}$ , we regard them as having no intersection, and remain k unchanged.
 $F\left(P\right)>0\wedge {y}_{p}={y}_{i+1}\wedge {y}_{i+1}>{y}_{i}$, P is on the frontleft side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2g). Although $\overrightarrow{{P}_{i}{P}_{i+1}}$ intersects $\overrightarrow{PQ}$ at ${P}_{i+1}$, we regard them as having no intersection, and k remains unchanged.
 $F\left(P\right)<0\wedge {y}_{p}={y}_{i}\wedge {y}_{i}>{y}_{i+1}$, P is on the backright side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2h). Although $\overrightarrow{{P}_{i}{P}_{i+1}}$ intersects $\overrightarrow{PQ}$ at ${P}_{i}$, we regard them as having no intersection, and k remains unchanged (similar to Case 7).
 $F\left(P\right)>0\wedge {y}_{i+1}>{y}_{p}>{y}_{i}$, P is on the leftmiddle side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2i). Thus, $\overrightarrow{{P}_{i}{P}_{i+1}}$ intersects $\overrightarrow{PQ}$ , and we set $k=k+1$.
 $F\left(P\right)<0\wedge {y}_{i}>{y}_{p}>{y}_{i+1}$, P is on the rightmiddle side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2j). Thus, $\overrightarrow{{P}_{i}{P}_{i+1}}$ intersects $\overrightarrow{PQ}$ , and we set $k=k+1$.
 ${y}_{p}>{y}_{i}\wedge {y}_{p}>{y}_{i+1}$, $\overrightarrow{{P}_{i}{P}_{i+1}}$ is on the right side of $\overrightarrow{PQ}$ (below) (see Figure 2k). Thus, both are disjoint, and k remains unchanged.
 $F\left(P\right)>0\wedge {y}_{p}<{y}_{i}\wedge {y}_{i+1}<{y}_{p}$, $\overrightarrow{PQ}$ is also on the left side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2l). Thus, both are disjoint, and k remains unchanged.
 $F\left(P\right)<0\wedge {y}_{p}<{y}_{i+1}\wedge {y}_{p}>{y}_{i}$, $\overrightarrow{PQ}$ is on the right side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2m). Thus, both are disjoint, and k remains unchanged.
 $F\left(P\right)<0\wedge {y}_{p}={y}_{i+1}\wedge {y}_{p}>{y}_{i}$, $\overrightarrow{PQ}$ is on the right side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2n). Thus, both are disjoint, and k remains unchanged.
 $F\left(P\right)>0\wedge {y}_{p}={y}_{i}\wedge {y}_{p}>{y}_{i+1}$, $\overrightarrow{PQ}$ is on the left side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2o). Thus, both are disjoint, and k remains unchanged.
 $F\left(P\right)=0\wedge {y}_{i}<{y}_{p}\wedge {y}_{p}<{y}_{i+1}$, P is on $\partial S$ $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2p).
 $P={P}_{i+1}\wedge {y}_{p}>{y}_{i}$, P is on $\partial S$ $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2q).
 $P={P}_{i}\wedge {y}_{p}>{y}_{i+1}$, P is on $\partial S$ $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2r).
 $F\left(P\right)=0\wedge {y}_{i}>{y}_{p}\wedge {y}_{p}>{y}_{i+1}$, P is on $\partial S$ $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2s).
 $P={P}_{i+1}\wedge {y}_{p}<{y}_{i}$, P is on $\partial S$ $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2t).
 $P={P}_{i}\wedge {y}_{p}<{y}_{i+1}$, P is on $\partial S$ $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2u).
 ${y}_{p}={y}_{i}={y}_{i+1}\wedge {x}_{i+1}<{x}_{i}<{x}_{p}$, $\overrightarrow{{P}_{i}{P}_{i+1}}$ and $\overrightarrow{PQ}$ are mutually separate, and both have opposite directions $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2v). Thus, they are disjoint, and k remains unchanged.
 ${y}_{p}={y}_{i}={y}_{i+1}\wedge {x}_{p}>{x}_{i+1}>{x}_{i}$, $\overrightarrow{{P}_{i}{P}_{i+1}}$ and $\overrightarrow{PQ}$ are disjoint $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2w), and k remains unchanged.
 $F\left(P\right)<0\wedge {y}_{i}={y}_{p}\wedge {y}_{p}<{y}_{i+1}$, P is on the backright side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ , and $\overrightarrow{{P}_{i}{P}_{i+1}}$ and $\overrightarrow{PQ}$ are disjoint $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2x). Thus, k remains unchanged.
 $F\left(P\right)>0\wedge {y}_{i+1}={y}_{p}\wedge {y}_{p}<{y}_{i}$, P is on the frontleft side of $\overrightarrow{{P}_{i}{P}_{i+1}}$ , and $\overrightarrow{{P}_{i}{P}_{i+1}}$ and $\overrightarrow{PQ}$ are disjoint $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2y). Thus, k remains unchanged.
 ${y}_{p}<{y}_{i}\wedge {y}_{p}<{y}_{i+1}$, $\overrightarrow{{P}_{i}{P}_{i+1}}$ is on the left side of $\overrightarrow{PQ}$ (above), and $\overrightarrow{{P}_{i}{P}_{i+1}}$ and $\overrightarrow{PQ}$ are disjoint $\overrightarrow{{P}_{i}{P}_{i+1}}$ (see Figure 2z). Thus, k remains unchanged.
 Class 1 includes Cases 3, 4, 9, and 10, for each of which $\overrightarrow{{P}_{i}{P}_{i+1}}$ intersects $\overrightarrow{PQ}$ . Therefore, we set $k=k+1$.
 Class 2 includes Cases 1, 2, and 16–21, for each of which P is on $\partial S$.
 Class 3 includes the remaining cases, for each of which $\overrightarrow{{P}_{i}{P}_{i+1}}$ and $\overrightarrow{PQ}$ are disjoint. Therefore, k remains unchanged.
 If the intersection of $\overrightarrow{PQ}$ and the $\overrightarrow{{P}_{i}{P}_{i+1}}$ (denoted by ${I}_{9}{J}_{10}$) in Figure 2i or Figure 2j is U, then ${I}_{9}{J}_{10}$ crosses $\overrightarrow{PQ}$ from one side to another. Since ${I}_{9}{J}_{10}$ belongs to the closed $\Gamma $, there must be another edge $\overrightarrow{{P}_{i}{P}_{i+1}}$ in Figure 2c,d,i, or Figure 2j that also intersects with $\overrightarrow{PQ}$ at another different intersection (denoted by ${V}_{1}$). Let us assume that ${V}_{1}={U}_{2}$. Therefore, $k=k+1=2$.
 Otherwise, if the intersection of $\overrightarrow{PQ}$ and the $\overrightarrow{{P}_{i}{P}_{i+1}}$ (denoted by ${C}_{3}{D}_{4}$) in Figure 2c or Figure 2d is U, then the other side connecting to U(denoted by $U38$) can only be the $\overrightarrow{{P}_{i}{P}_{i+1}}$ in Figure 2c–g, or Figure 2h.Besides, our proof for Lemma 1 is divided into the following three main substeps.
 (a)
 If $U38$ is the $\overrightarrow{{P}_{i}{P}_{i+1}}$ (denoted by ${C}_{3}^{1}{D}_{4}^{1}$) in Figure 2c or Figure 2d, then $\overrightarrow{PQ}$ and ${C}_{3}^{1}{D}_{4}^{1}$ must produce a new intersection (denoted by ${V}_{2}$), which is equal to U and let us assume that ${V}_{2}={U}_{2}$. ${U}_{2}$ increases the number of intersections of $\Gamma $ and $\overrightarrow{PQ}$ by 1. Therefore, $k=k+1=2$.
 (b)
 Otherwise, if $U38$ is the $\overrightarrow{{P}_{i}{P}_{i+1}}$ (denoted by ${E}_{5}{F}_{6}$) in Figure 2e or Figure 2f, then ${E}_{5}{F}_{6}$ belongs to the closed $\Gamma $ of S. Then, next, the other side connecting to ${E}_{5}{F}_{6}$ (denoted by $U{38}^{1}$) can only be the $\overrightarrow{{P}_{i}{P}_{i+1}}$ in Figure 2c–g, or Figure 2h.
 If $U{38}^{1}$ is the $\overrightarrow{{P}_{i}{P}_{i+1}}$ (denoted by ${C}_{3}^{2}{D}_{4}^{2}$) in Figure 2c or Figure 2d, then $\overrightarrow{PQ}$ and ${C}_{3}^{2}{D}_{4}^{2}$ must produce a new intersection, which is different from U (denoted by ${V}_{3}$). Let us assume that ${V}_{3}={U}_{2}$. Therefore, $k=k+1=2$.
 Otherwise, if $U{38}^{1}$ is the $\overrightarrow{{P}_{i}{P}_{i+1}}$ (denoted by ${G}_{7}{H}_{8}$) in Figure 2g or Figure 2h, then the path ${C}_{3}{D}_{4}\to {E}_{5}{F}_{6}\to {G}_{7}{H}_{8}$ crosses $\overrightarrow{PQ}$ from one side to another. Since ${G}_{7}{H}_{8}$ belongs to the closed $\Gamma $ of, there must be another edge $\overrightarrow{{P}_{i}{P}_{i+1}}$ in Figure 2c,d,i, or Figure 2j that also intersects with $\overrightarrow{PQ}$ at another different intersection (denoted by ${V}_{4}$). Let us assume that ${V}_{4}={U}_{2}$. Therefore, $k=k+1=2$.
 (c)
 Otherwise, if $U38$ is the $\overrightarrow{{P}_{i}{P}_{i+1}}$ (denoted by ${G}_{7}{H}_{8}$) in Figure 2g or Figure 2h, the path ${C}_{3}{D}_{4}\to {G}_{7}{H}_{8}$ crosses $\overrightarrow{PQ}$ from one side to another. Since ${G}_{7}{H}_{8}$ belongs to the closed $\Gamma $, there must be another edge $\overrightarrow{{P}_{i}{P}_{i+1}}$ in Figure 2c,d,i, or Figure 2j that also intersects with $\overrightarrow{PQ}$ at another different intersection (denoted by ${V}_{5}$). Let us assume that ${V}_{5}={U}_{2}$. Therefore, $k=k+1=2$.
 If P is on the boundary of S, then P is on an edge vector of S. Therefore, by Definition 4, it follows that the point P is oddeven number $S\left(P\right)=1$.
 Otherwise, if P is outside S and $\overrightarrow{PQ}$ does not intersect any edge of S, then $S\left(P\right)=0$ by Definition 4.
 Otherwise, if P is outside the $outer$ $ring$ of S (see Definition 1) and condition the number of intersections $>0$ holds between $\overrightarrow{PQ}$ and all edges of S, below let us prove that the number of intersections is even.Let us assume that $\overrightarrow{PQ}$ intersects with the $rings$ ${\Gamma}_{1}$, ${\Gamma}_{2}$, ⋯, ${\Gamma}_{l}$ of S. By Lemma 1, it follows that the number of intersections produced by $\overrightarrow{PQ}$ and all edges of $ring$ ${\Gamma}_{i}$ is an even for $i=1,2,\cdots ,l$. Therefore, the total number of intersections produced by $\overrightarrow{PQ}$ and the $rings$ ${\Gamma}_{1}$, ${\Gamma}_{2}$, ⋯, ${\Gamma}_{l}$ of S is an even and this conclusion that $S\left(P\right)$ is even holds.
 Otherwise, if P is inside the $outer$ $ring$ of S (see Definition 1). Let us assume that ${\Gamma}_{1},{\Gamma}_{2},\cdots ,{\Gamma}_{l}$ are all rings of S each of which the P is outside. Similarly, let us assume that ${\gamma}_{1},{\gamma}_{2},\cdots ,{\gamma}_{m}$ are all rings of S each of which the P is within.By the necessity of Lemma 1, it follows that the number of intersections between $\overrightarrow{PQ}$ and ${\Gamma}_{i}$ is an even for $i=1,2,\cdots ,l$. As a result, the total number of intersections produced by $\overrightarrow{PQ}$ and ${\Gamma}_{i}$ is an even with $i=1,2,\cdots ,l$.Similarly, by the necessity of Lemma 2, it follows that the number of intersections between $\overrightarrow{PQ}$ and ${\gamma}_{i}$ is an odd(denoted by ${t}_{i}$) for $i=1,2,\cdots ,m$. As a result, the total number of intersections produced by $\overrightarrow{PQ}$ and ${\gamma}_{i}$ with $i=1,2,\cdots ,m$ is $\sum _{i=1}^{m}{t}_{i}$ whose parity is consistent with the parity of m.Accordingly, if m is an even, then the k that denotes the number of intersections made by $\overrightarrow{PQ}$ and all edges of S is also an even, and vice versa.Eventually, when P is inside the $outer$ $ring$ of S, by Definition 4, it follows that
 (a)
 If the k is even, then the P is outside S and $S\left(P\right)$ is even.
 (b)
 Conversely, if the k is odd, then the P is inside S and $S\left(P\right)$ is odd.
Algorithm 1: Determine whether P is inside, outside, or on $\partial S$. It cannot solve the problem of instability that can result from the comparison operations of floatingpoint numbers. 
4. A Serial Algorithm for the PointinPolygon Test
5. Boolean Operations Principle and Algorithm
Algorithm 2: Performing boolean operations on two polygons. 

 1.
 If the oddeven number $S\left({R}_{k}\right)=0$, to calculate $S\left({R}_{k+1}\right)$ one needs only to recheck the edges of S belonging to Cases 5–8 (see Figure 2). Likewise, if the oddeven number $S\left({T}_{k}\right)$ $=0$, to calculate $S\left({T}_{k+1}\right)$, one needs only to recheck the edges of S belonging to Cases 7–15 (see Figure 2).
 2.
 If the oddeven number $S\left({R}_{k}\right)$ is even or odd, to calculate $S\left({R}_{k+1}\right)$ one needs only to recheck the edges of S belonging to Cases 3–10 (see Figure 2). Likewise, if the oddeven number $S\left({T}_{k}\right)$ is even or odd, to calculate $S\left({T}_{k+1}\right)$, one needs only to recheck the edges of S belonging to Cases 7–15 (see Figure 2).
 3.
 If the oddeven number $S\left({R}_{k}\right)=1$, to calculate $S\left({R}_{k+1}\right)$, one needs only to recheck the edges of S belonging to Cases 1–10 (see Figure 2). Likewise, if the oddeven number $S\left({T}_{k}\right)=1$, to calculate $T\left({R}_{k+1}\right)$, one needs only to recheck the edges of S belonging to Cases 7–19 (see Figure 2).
6. Complexity Analysis of Algorithms
7. Experiment and Comparison
7.1. The PointinPolygon Test
7.2. Boolean Operations Test
8. Results and Discussion
 It handles all degenerate cases and simultaneously provides a corresponding solution to each degenerate case (see Figure 2). These tactics both ensure its robustness and creates the prerequisites and basis for Algorithm 2.
 It uses Equation (3) to reduce the running time.
 It uses the Jordan property of a vector to determine the positional relationship between a point and an edge, which avoids computing the intersection point and division operations.
 It involves only addition, subtraction, multiplication, comparison, and logical operations such that it is unnecessary to compute any angle. In addition, It eliminates other timeconsuming operations such as preprocessing.
 It does not impose any restrictions on the shape of input polygons, and is applicable to any polygons, including selfintersecting polygons or polygons with holes nested to any level of depth (see Figure 3a). Therefore, It can both quickly determine whether a point is inside or outside a polygon and accurately determine the contours of input polygon (see Figure 3b).
 It does not need to sort the vertices clockwise or counterclockwise beforehand. Therefore, it processes all edges one by one in any order for each input polygon.
 It is parallelizable because its many operations can be done in parallel.
 A detailed theoretical analysis and the proof of the correctness of Algorithm 1 (see Theorems 1) for the pointinpolygon test are shown.
 It considers the execution probability of each conditional branch and uses these probabilities to optimize the program flow.
9. Conclusions and Future Works
Author Contributions
Funding
Acknowledgments
Conflicts of Interest
References
 Jiménez, J.J.; Feito, F.R.; Segura, R.J. Robust and Optimized Algorithms for the PointinPolygon Inclusion Test without Preprocessing. Comput. Graph. Forum 2009, 28, 2264–2274. [Google Scholar] [CrossRef]
 Hormann, K.; Agathos, A. The point in polygon problem for arbitrary polygons. Comput. Geom. 2001, 20, 131–144. [Google Scholar] [CrossRef]
 DonaldHearn. Computer Graphics C Version; Prentice Hall: Upper Saddle River, NJ, USA, 1997. [Google Scholar]
 Haines, E. Point in polygon strategies. Graph. Gems IV 1994, 994, 24–46. [Google Scholar]
 Haines, E. Graphics Gems Repository. Available online: http://tog.acm.org/resources/GraphicsGems/ (accessed on 7 August 2018).
 Galacticomm. A Point about Polygons (Article in 3/97 Linux Journal). Available online: http://www.visibone.com/inpoly/ (accessed on 7 August 2018).
 Weiler, K. Polygon comparison using a graph representation. SIGGRAPH Comput. Graph. 1980, 14, 10–18. [Google Scholar] [CrossRef]
 Hoy, M.B. 3D Printing: Making Things at the Library. Med. Ref. Serv. Q. 2013, 32, 93–99. [Google Scholar] [CrossRef] [PubMed]
 Nievergelt, J.; Preparata, F.P. Planesweep algorithms for intersecting geometric figures. Commun. ACM 1982, 25, 739–747. [Google Scholar] [CrossRef] [Green Version]
 Galetzka, M.; Glauner, P.O. A correct evenodd algorithm for the pointinpolygon (PIP) problem for complex polygons. arXiv, 2012; arXiv:1207.3502. [Google Scholar]
 Wang, W.; Li, J.; Wu, E. 2D pointinpolygon test by classifying edges into layers. Comput. Graph. 2005, 29, 427–439. [Google Scholar] [CrossRef]
 Sederberg, T.W.; Nishita, T. Curve intersection using Bézier clipping. Comput. Aided Des. 1990, 22, 538–549. [Google Scholar] [CrossRef]
 Bartoň, M.; Jüttler, B. Computing roots of polynomials by quadratic clipping. Comput. Aided Geom. Des. 2007, 24, 125–141. [Google Scholar] [CrossRef]
 Aizenshtein, M.; Bartoň, M.; Elber, G. Global solutions of wellconstrained transcendental systems using expression trees and a single solution test. Comput. Aided Geom. Des. 2012, 29, 265–279. [Google Scholar] [CrossRef]
 Van Sosin, B.; Elber, G. Solving piecewise polynomial constraint systems with decomposition and a subdivisionbased solver. Comput. Aided Des. 2017, 90, 37–47. [Google Scholar] [CrossRef]
 Gombos˘i, M.; Žalik, B. Pointinpolygon tests for geometric buffers. Comput. Geosci. 2005, 31, 1201–1212. [Google Scholar] [CrossRef]
 Yang, S.; Yong, J.H.; Sun, J.; Gu, H.; Paul, J.C. A pointinpolygon method based on a quasiclosest point. Comput. Geosci. 2010, 36, 205–213. [Google Scholar] [CrossRef] [Green Version]
 Lorenzetto, G.P.; Datta, A.; Thomas, R.C. A fast trapezoidation technique for planar polygons. Comput. Graph. 2002, 26, 281–289. [Google Scholar] [CrossRef] [Green Version]
 Martínez, F.; Rueda, A.J.; Feito, F.R. The multiLREP decomposition and its application to a pointinpolygon inclusion test. Comput. Graph. 2006, 30, 947–958. [Google Scholar] [CrossRef]
 Rueda, A.J.; Feito, F.R. ELREP: A New 2D Geometric Decomposition Scheme and Its Applications. IEEE Trans. Vis. Comput. Graph. 2011, 17, 1325–1336. [Google Scholar] [CrossRef] [PubMed]
 Andreev, R.D. Algorithm for Clpping Arbitrary Polygons. Comput. Graph. Forum 1989, 8, 183–191. [Google Scholar] [CrossRef]
 Rappoport, A. An efficient algorithm for line and polygon clipping. Vis. Comput. 1991, 7, 19–28. [Google Scholar] [CrossRef]
 Greiner, G.; Hormann, K. Efficient clipping of arbitrary polygons. ACM Trans. Graph. 1998, 17, 71–83. [Google Scholar] [CrossRef]
 Weiler, K.; Atherton, P. Hidden surface removal using polygon area sorting. SIGGRAPH Comput. Graph. 1977, 11, 214–222. [Google Scholar] [CrossRef]
 Vatti, B.R. A generic solution to polygon clipping. Commun. ACM 1992, 35, 56–63. [Google Scholar] [CrossRef]
 Martínez, F.; Rueda, A.J.; Feito, F.R. A new algorithm for computing Boolean operations on polygons. Comput. Geosci. 2009, 35, 1177–1185. [Google Scholar] [CrossRef]
 Feito, F.R.; Rivero, M. Geometric modelling based on simplicial chains. Comput. Graph. 1998, 22, 611–619. [Google Scholar] [CrossRef]
 Rivero, M.; Feito, F.R. Boolean operations on general planar polygons. Comput. Graph. 2000, 24, 881–896. [Google Scholar] [CrossRef]
 Peng, Y.; Yong, J.H.; Dong, W.M.; Zhang, H.; Sun, J.G. A new algorithm for Boolean operations on general polygons. Comput. Graph. 2005, 29, 57–70. [Google Scholar] [CrossRef] [Green Version]
 Graysmith, J.; Shaw, C. Automated procedures for Boolean operations on finite element meshes. Eng. Comput. 1997, 14, 702–717. [Google Scholar] [CrossRef]
 CGAL4.2. CGAL—Computational Geometry Algorithms Library. Available online: http://www.cgal.org/ (accessed on 7 August 2018).
 GPC, A.M. GPC General Polygon Clipper Library from The University of Manchester. Available online: http://www.cs.man.ac.uk/toby/alan/software/ (accessed on 7 August 2018).
 Clipper4.6.3. Clipper—An Open Source Freeware Polygon Clipping Library. Available online: http://www.angusj.com/delphi/clipper.php (accessed on 7 August 2018).
Properties  CROSS  HOLE  NHOLE  KHOLE  DIR  SENS  ON  BUG  

Result  
Library  
1  Algorithm 1  ✓  ✓  ✓  ✓  ✗  ✗  ✓  ✗  
2  Crossings  ✗  ✓  ✗  ✗  ✗  ✗  ✗  ✗  
3  Crossingsmultiply [4,5]  ✓  ✓  ✗  ✓  ✗  ✗  ✗  ✗  
4  Angle summation  ✓  ✓  ✗  ✓  ✗  ✗  ✗  ✗  
5  Weiler angle summation  ✗  ✓  ✗  ✗  ✗  ✗  ✗  ✗  
6  Halfplane testing  ✓  ✓  ✗  ✓  ✗  ✗  ✗  ✓  
7  Barycentric coordinates  ✓  ✓  ✗  ✓  ✗  ✗  ✗  ✓  
8  Spackman barycentric  ✓  ✓  ✗  ✓  ✗  ✗  ✗  ✓  
9  Trapezoid testing  ✗  ✓  ✗  ✗  ✗  ✗  ✗  ✓  
10  Grid testing  ✓  ✓  ✗  ✓  ✗  ✗  ✗  ✓  
11  Exterior test  ✗  ✓  ✗  ✗  ✗  ✗  ✗  ✗  
12  Inclusion test  ✗  ✓  ✗  ✗  ✗  ✗  ✗  ✗  
13  Jiménez et al. [1]  ✗  ✓  ✗  ✗  ✓  ✓  ✗  ✓  
14  Galacticomm [6]  ✓  ✓  ✗  ✓  ✗  ✗  ✗  ✗  
15  Efficient boundary [2]  ✗  ✗  ✗  ✗  ✓  ✓  ✗  ✓  
16  CGAL4.2 [31]  ✓  ✓  ✓  ✓  ✗  ✗  ✓  ✗ 
© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
Share and Cite
Hao, J.; Sun, J.; Chen, Y.; Cai, Q.; Tan, L. Optimal Reliable PointinPolygon Test and Differential Coding Boolean Operations on Polygons. Symmetry 2018, 10, 477. https://doi.org/10.3390/sym10100477
Hao J, Sun J, Chen Y, Cai Q, Tan L. Optimal Reliable PointinPolygon Test and Differential Coding Boolean Operations on Polygons. Symmetry. 2018; 10(10):477. https://doi.org/10.3390/sym10100477
Chicago/Turabian StyleHao, Jianqiang, Jianzhi Sun, Yi Chen, Qiang Cai, and Li Tan. 2018. "Optimal Reliable PointinPolygon Test and Differential Coding Boolean Operations on Polygons" Symmetry 10, no. 10: 477. https://doi.org/10.3390/sym10100477