Peeling Digital Potatoes

Peeling Digital Potatoes

Loïc Crombez
Université Clermont Auvergne and
LIMOS
Clermont-Ferrand, France
lcrombez@isima.fr
   Guilherme D. da Fonseca
Université Clermont Auvergne and
LIMOS
Clermont-Ferrand, France
fonseca@isima.fr
   Yan Gérard
Université Clermont Auvergne and
LIMOS
Clermont-Ferrand, France
yan.gerard@uca.fr
Abstract

The potato-peeling problem (also known as convex skull) is a fundamental computational geometry problem and the fastest algorithm to date runs in time for a polygon with vertices that may have holes. In this paper, we consider a digital version of the problem. A set is digital convex if , where denotes the convex hull of . Given a set of lattice points, we present polynomial time algorithms to the problems of finding the largest digital convex subset of (digital potato-peeling problem) and the largest union of two digital convex subsets of . The two algorithms take roughly and time, respectively. We also show that those algorithms provide an approximation to the continuous versions.

Acknowledgements

A preliminary version of this paper has been presented at the Young Researchers Forum, during CG Week 2018. This work has been sponsored by the French government research program “Investissements d’Avenir” through the IDEX-ISITE initiative 16-IDEX-0001 (CAP 20-25).

1 Introduction

The potato-peeling problem [Goo81] (also known as convex skull [Woo86]) consists of finding the convex polygon of maximum area that is contained inside a given polygon (possibly with holes) with vertices. The fastest exact algorithm known takes time without holes and if there are holes [ChY86]. The problem is arguably the simplest geometric problem for which the fastest exact algorithm known is a polynomial of high degree and this high complexity motivated the study of approximation algorithms [CCKS17, HKKM06]. Multiple variations of the problem have been considered, including triangle-mesh [AVLS11] and orthogonal [DBBB11, WoY88] versions. In this paper, we consider a digital geometry version of the problem.

Digital geometry is the field of mathematics that studies the geometry of points with integer coordinates, also known as lattice points [KlR04]. Different definitions of convexity in have been investigated, such as digital line, triangle, line [KR82], HV (for Horizontal and Vertical [BDNP96]), and Q (for Quadrant [Da01]) convexities. These definitions guarantee that a digital convex set is connected (in terms of the induced grid subgraph), which simplifies several algorithmic problems.

Throughout this paper, however, we use the original definition of digital convexity from the geometry of numbers [Gru93]. A set of lattice points is digital convex if , where denotes the continuous convex hull of . This definition does not guarantee connectivity of the grid subgraph, but provides several other important mathematical properties, such as being preserved under certain affine transformations. The authors recently showed how to efficiently test digital convexity in the plane [CDG19]. A natural question is to determine the largest digital convex subset.

The digital potato-peeling problem is defined as follows and is illustrated in Figure 1(a,b).

Problem 1 (Digital potato-peeling).

Given a set of lattice points described by their coordinates, determine the largest set that is digital convex (i.e. ), where largest refers to the area of .

Figure 1: (a) Input lattice set . (b) Largest digital convex subset of (Problem 1). (c) Largest union of two digital convex subsets of (Problem 2).

Heuristics for the digital potato-peeling problem have been presented in [BoS05, ChC05], but no exact algorithm has been presented. We also consider the question of covering the largest area with two digital convex subsets. The problem is defined as follows and is illustrated in Figure 1(a,c).

Problem 2 (Digital 2-potato peeling).

Given a set of lattice points described by their coordinate, determine the largest set such that and are both digital convex, where largest refers to the area of .

A related continuous problem consists of completely covering a polygon by a small number of convex polygons inside of it. O’Rourke showed that covering a polygon with the minimum number of convex polygons is decidable [Oro82, Oro82-2], but the problem has been shown to be NP-Hard with or without holes [CuR94, Oro83]. Shermer [She93] presents a linear time algorithm for the case of two convex polygons and Belleville [Bel93] provides a linear time algorithm for three. We are not aware of any previous results on finding a fixed (non-unit) number of convex polygons inside a given polygon and maximizing the area covered.

Our results

We present polynomial time algorithms to solve each of these two problems. In Section 2, we show how to solve the digital potato-peeling problem in time, where is the diameter of the input . Our algorithm builds the convex polygon through its triangulation, using a triangle range counting data structure [CSW92] together with Pick’s theorem to test the validity of each triangle. The factor comes from the gcd computation to apply Pick’s theorem. Our algorithm makes use of the following two properties: (i) it is possible to triangulate using only triangles that share a common bottom-most vertex and (ii) if the polygons lying on both sides of one such triangle (including the triangle itself) are convex, then the whole polygon is convex.

These two properties are no longer valid for Problem 2, in which the solution is the union of two convex polygons. Also, since convex shapes are not pseudo-disks (the boundaries may cross an arbitrarily large number of times), separating the input with a constant number of lines is not an option. Instead of property (i), our approach uses the fact that the union of two (intersecting) convex polygons can be triangulated with triangles that share a common vertex (that may not be a vertex of either convex polygon). Since may not have integer coordinates, we can no longer use Pick’s theorem, and resort to the formulas from Beck and Robins [BeR02] or the algorithm from Barvinok [Bar94] to count the lattice points inside each triangle in time.

Furthermore, to circumvent the fact the solution no longer obeys property (ii), we use a directed acyclic graph (DAG) that encapsulates the orientation of the edges of both convex polygons. For those reasons, the running time of our algorithm for Problem 2 increases to . The corresponding algorithm is described in Section 3.

In Section 4, we show that a solution to the digital version of the problems provides an approximation to the continuous versions, establishing a formal connection between the continuous and digital versions.

Reducing the complexity of our algorithms or extending the result to higher numbers of convex polygons remain intriguing open questions, which are discussed in Section 5.

2 Digital Potato Peeling

In this section, we present an algorithm to solve the digital potato-peeling problem in time, where is the number of input points and is the diameter of the point set. We start by describing an algorithm that runs in roughly time, and then show how to modify it to obtain our final running time.

2.1 First Algorithm

A digital convex set can be described by its convex hull and the vertices are lattice points. Instead of explicitly building , our algorithm constructs . Note that it is always possible to triangulate a convex polygon with vertices using triangles that share a bottom-most vertex (fan triangulation). We first consider the following rooted variation of the digital potato-peeling problem, where the point has been given as part of the input.

Problem 3 (Rooted digital potato peeling).

Given a set of lattice points given by their coordinates and a point , determine the largest set that is digital convex and has as the right-most point at the bottom-most row of .

Without loss of generality, we may assume that all points in lie either on the same row or on a row above and all points on the same row of are to the left of . We refer to as the root. Let denote the points of sorted clockwise around , starting from the left. Note that pruning and sorting the input takes time.

Let denote the (closed) triangle whose vertices are with . We say that a triangle is valid if . To algorithmically verify that is valid, we compare and . The value of is determined as follows. Pick’s theorem says that the area of a triangle with lattice vertices is equal to , where is the number of boundary lattice points and is the number of interior lattice points. The value of can be computed using a computation for each edge in time, where is the diameter of the triangle. Plugging in the area of the triangle, we obtain the number of lattice points . To compute we use a triangle range counting query. Those queries can be answered in time after preprocessing in time [CSW92]. Since the diameter of lattice points is , the term dominates the complexity and the total time to test the validity of a triangle (after preprocessing) is .

The algorithm incrementally builds the fan triangulation of by appending valid triangles from left to right using dynamic programming. At each step, we ensure the digital convexity through the following property. Let be the convex hull of a digital convex set rooted at with as the right-most triangle. If is valid and is convex, then is digital convex.

For all with and such that is valid, the algorithm determines the largest convex polygon that has as the right-most triangle. We refer to this convex polygon as . The key property to efficiently compute is

A naïve dynamic programming algorithm to compute , solving Problem 3, takes time, since there are values of to be calculated and each calculation involves computing the maximum among previously calculated values and testing if one triangle is valid.

We can now return to our original digital potato-peeling problem (Problem 1) by testing all possible values of . The total running time increases by a factor of and is therefore . In the next section, we show how to reduce the running time to .

2.2 Faster Algorithm

Again, we start by solving Problem 3 using a dynamic programming construction of . For each value of , we sort the all valid for in counter-clockwise order of around into a list of triangles , obtaining lists of triangles each. Sorting each list takes time, which gives a total of time. Moreover, testing the validity of each triangle takes time, which gives a total of , since . Next, explain the dynamic programming part of the algorithm.

For each from to , we do the following. First, we sort all values of for by decreasing area into a list . Then, we consider every in the order given by , testing each from the largest area to the smallest. If is convex, then we set . Otherwise, we permanently remove from the list . Next, we justify the correctness of this procedure, especially the fact that we are allowed to remove the aforementioned values of from .

Since we sorted the list of counter-clockwise by around , we have the following key property. For each preceding in the ordering , we have that for all if is not convex, then is not convex either. Hence, the values of removed from cannot form a convex polygon with the triangles that appear later in the list .

The running time of the dynamic programming part for each value of is dominated by the time for sorting. The remaining part takes time because at each step, we either remove a convex polygon from or we advance through the list of triangles . Considering all values of and the initial sorting, the total time to solve Problem 3 is .

In order to solve Problem 1, we test all possible values of , proving the following theorem.

Theorem 1.

There exists an algorithm to solve Problem 1 (digital potato peeling) in time, where is the number of input points and is the diameter of the input.

3 Digital 2-Potato Peeling

In this section, we show how to find two digital convex sets , maxizing the area of . Either the two convex hulls intersect or they do not (Figure 2). We treat those two cases separately and the solution to Problem 2 is the largest among tne two. Hence, we consider the two following variations of the 2-potato-peeling problem.

Problem 4 (Disjoint 2-potato peeling).

Given a set of lattice points given by their coordinates, determine the largest two digital convex sets such that .

Problem 5 (Intersecting 2-potato peeling).

Given a set of lattice points given by their coordinates, determine the largest union of two digital convex sets such that . In this case, largest means the maximum area of .

Figure 2: (a) The two optimal sets intersect. (b) The two optimal sets are disjoint and there is a supporting separating line.

3.1 Disjoint Convex Polygons

It is well known that any two disjoint convex shapes can be separated by a straight line. Moreover two convex polygons can be separated by a supporting line of an edge of one of the convex polygons that contains no vertex of the other convex polygon (Figure 2(b)).

For each ordered pair of distinct points , we define two subsets . The set contains the points on the line or to the left of it (according to the direction ). The set contains the remaining points of .

For each pair of sets , we independently solve Problem 1 for each of and . Since there are pairs and each pair takes time, we solve Problem 4 in time.

3.2 Intersecting Convex Polygons

The more interesting case is when the two convex polygons intersect (Problem 5). Note that it is possible to triangulate the union of two convex polygons that share a common boundary point using a fan triangulation around (Figure 3). Hence we consider the following rooted version of the problem.

Problem 6 (Rooted 2-potato peeling).

Given a set of lattice points represented by their coordinates and two edges that cross at a point , determine the largest union of two digital convex sets such that is an edge of and is an edge of .

Figure 3: (a) A fan triangulation of two intersecting convex polygons from a point . (b) Definitions used to solve Problem 6.

Let be the intersection point of . The strategy of the algorithm to solve Problem 6 is to encode the problem into a DAG whose longest directed path corresponds to the desired solution. To avoid confusion, we use the terms node and arc for the DAG and keep the terms vertex and edge for the polygons. It is well known that the longest directed path in a DAG can be calculated in time [SeW11].

Let be the set of valid triangles with two vertices from and as the remaining vertex. The nodes are ordered pairs of valid triangles and a starting node . The number of nodes is . Before we define the arcs, we give an intuitive idea of our objective.

Each node is such that (resp. ) is used to build the fan triangulation of (resp. ). The arcs will be defined in a way that, at each step as we walk through a path of the DAG, either we add one triangle to or to . The arcs enforce the convexity of both and . Furthermore, we enforce that we always append a triangle to the triangulation that is further behind (in clockwise order), unless we have already reached the last triangle of . This last condition is important to allow us to define the arc lengths in a way that corresponds to the area of the union of the two convex polygons. Figure 4 illustrates the result of following a path on the DAG.

Figure 4: Steps of the algorithm from Section 3.2. Figure (a) represents the solution, while Figures (b) to (h) represent the triangulation obtained at each node of a path. The newly covered area that is assigned as the length of the corresponding arc is marked. In (b), we have the initial pair of edges which corresponds to the starting vertex . After following a type-0 arc, a first pair of triangles with vertices and is obtained in (c). The triangle is brown and triangle yellow. From (c) to (d), we follow a type-1 arc. The triangle (less advanced than triangle ) advances. From (d) to (e), we follow a type-2 arc, since triangle is less advanced. From (e) to (f) we have again a type-2 arc, and from (f) to (g) we have a type-1 arc. In (g), the triangle has reached the final node and cannot advance anymore. We have only type-2 arcs to follow until reaches , at a node in .

The edge (respectively, ) from the problem input defines two halfplanes, one on each side. Let (resp. ) be the halfplane that contains (resp. ). We have not yet determined or , but all four possibilities of halfplanes may be tried independently. Assume without loss of generality that all points of lie in the region . Let be the points of sorted clockwise around . The edge (resp. ) has (resp. ) as a vertex. We define the indices such that (Figure 3).

We are now ready to define the set of arcs of the DAG. There are three types of arcs. The type-0 arcs start from the initial node to if is a vertex of and a vertex of . These two triangles of vertices with and with are respectively bounded by the edges and . They initialize the triangulations of our two polygons and . There are type-0 arcs.

A type-1 arc corresponds to advancing the triangulation of , while a type-2 arc corresponds to advancing the triangulation of . There are type- arcs coming out of each node. A type-1 arc goes from to if:

  • the quadrilateral is convex,

  • has vertices with ,

  • has vertices with ,

  • has vertices with ,

  • and .

Similarly, there is a type-2 arc from to if:

  • the quadrilateral is convex,

  • has vertices with ,

  • has vertices with ,

  • has vertices with ,

  • and either or .

The length of each arc corresponds to the area of the new region covered by appending a new triangle by following the arc. Therefore, the length of a type-0 arc from to is the area of . The length of a type-1 arc from to is defined as the area of . Similarly, the length of a type-2 arc from to is defined as the area of .

We define a set of end nodes as follows. A node is an end node if is a vertex of and is a vertex of . The construction of the DAG allows us to prove the following lemma.

Lemma 2.

There is a bijection between the directed paths of the DAG (starting from and ending in ) and the digital convex sets such that is an edge of and is an edge of . Furthermore, the length of each path is equal to the corresponding area of . (We assume that (resp. ) lie above the supporting line of (resp. ).)

Proof.

First we show that the existance of two digital convex sets as in the lemma statement implies the existance of a directed path in the DAG as in the lemma statement. Let (resp. ) be two convex sets lying above the supporting line of (resp. ). Both and contain as a boundary point and hence can be triangulated from . It is easy to see that there is a path corresponding to this triangulation. Next, we show the converse also holds.

The definition of the arcs is such that advancing through one of them adds a triangle to one of the two polygons while preserving convexity, which ensures that all paths correspond to convex polygons. Furthermore, the starting node ensures that the two convex polygons respectively start from and , while the set of ending nodes ensure that the two convex polygons respectively end at and . Hence all paths from to correspond to two convex polygons that fit the lemma statement, one from edge and one from edge . The validity test on each triangle ensures that the paths describe digital convex sets.

The definition of the arcs enforces that we only move forward the least advanced triangle, that is the triangle that has the minimum maximum index among its vertices. The only exception is when is completed, that is the triangle with vertex has been added to its triangulation. This ensures that the new area covered by a type- arc is simply the set theoretic difference of two triangles (instead of a triangle and an arbitrary convex object). As the length of the arcs is defined as the area of the difference of the two triangles, the total length of the path is equal to the area of the union of the two convex polygons. Hence each path from to describe two digital convex sets such that is an edge of and is an edge of , and the length of each path is equal to the corresponding area of . ∎

Theorem 3.

There exists an algorithm to solve Problem 2 (digital 2-potato peeling) in time, where is the number of input points and is the diameter of the input.

Proof.

As explained in Section 3.1, solving the disjoint case (Problem 4) takes time. Next, we show how to solve the rooted intersecting case (Problem 6) in time, proving the theorem.

Assume without loss of generality that are respectively above the supporting lines of (all four possibilities may be tried independently). Our algorithm starts by computing the DAG with nodes, each representing a pair of triangles. Since each node at most incoming arcs, the number of arcs is . Hence the longest path can be found in time.

To build the set of nodes , we need to test the validity of triangles. Since may not be a lattice point, Pick’s theorem cannot be used. Still, is a rational point with denominators bounded by . Hence, we can use either the formulas from Beck and Robins [BeR02] or the algorithm from Barvinok [Bar94] to calculate the number of lattice points inside each triangle in time. As in Section 2, we compute using a triangle range counting query, which takes time after preprocessing in time [CSW92]. The triangle is valid if and only if . The two steps to test the validity of a triangle take and time. Since the diameter of lattice points is , the dominating term is . Hence, we test the validity of each triangle in time, which gives a total time of to build .

Consequently, we solve Problem 6 in time. To obtain a solution to Problem 2, we note that there are candidates for the edge , as well as for the edge . Testing all possible edges , we achieve the claimed running time of time. ∎

4 From Digital to Continuous

In this section, we show that the exact algorithms for the digital potato-peeling problem and the digital 2-potato-peeling problem can be used to compute an approximation of the respective continuous problems with an arbitrarily small approximation error. For simplicity, we focus on the potato-peeling problem, but the 2-potato-peeling case is analogous.

Problem 7 (Continuous potato-peeling).

Given a polygon (that may have holes) of vertices, determine the largest convex polygon , where largest refers to the area of .

We start with some definitions. Let be the area of the optimal solution to the continuous problem above and be the area of . Given an approximation parameter , we show how to obtain a set of lattice points such that the area of the convex hull of the solution of Problem 1 with input satisfies . In this section, we use lattice points that are not integers, but points with coordinates that are multiples of . Let denote the set of all points with coordinates that are multiple of . Of course, a uniform scaling maps to the integer lattice used in the remainder of the paper, and hence the integer lattice algorithms also apply to .

For a polygon , the erosion of , denoted is the subset of formed by points within distance at least of all points outside (Figure 5(a)). Let be the area of the optimal solution to the continuous potato-peeling problem with input . The width of is the minimum distance between two parallel lines such that is between and .

The following lemma that bounds the area difference between a convex polygon and the convex hull of its intersection with a lattice set will be useful to our proof.

Lemma 4.

Let be a convex polygon of diameter . The convex hull verifies

Proof.

The lattice induces a grid with vertex set and square cells of side length . Let be the set of grid cells that are completely contained in and be the set of cells that are partially contained in . All cells in intersect the boundary of .

Since the perimeter of a convex shape is at most times its diameter [AHM07], the perimeter of is at most . Since a curve of perimeter intersects at most grid cells of side length [GeVF16], we have .

All cells in are contained in and is covered by . Therefore, the area of is at most the area in , which is

proving the lemma. ∎

The following lemma bounds the area difference between the optimal solutions of the continuous potato peeling problem with inputs and .

Lemma 5.

Let be a polygon of diameter and be the erosion of . Let (resp. ) denote the largest convex polygon inside (resp. ). We have the following inequality:

Proof.

The erosion of is a convex polygon that lies inside . Hence the area of is at least as large as the area of .

As is a convex polygon of diameter at most , the perimeter of is at most . As every eroded points from in order to obtain are inside and at a maximum distance of of the boundary of , they are all included inside a set of rectangles that lie inside with the edges of as sides and width . Hence, the area difference between and its erosion is at most , which proves the lemma. ∎

The digital solution may have portions that lie outside the input polygon of the continuous version. However, this portion cannot be too big, as shown in the following lemma.

Figure 5: (a) A polygon , its erosion , and the set . (b) To include the point that is outside , has to go between the lattice points within distance of .
Lemma 6.

Let be a polygon of diameter and be the erosion of . Let , and be the largest digital convex subset of . The following inequality holds:

Proof.

Let be a point in . As is included inside , all the lattice within distance of are not in (see Figure 5). All lattice points at a distance less than of are not in . Hence, in order to include , has to lie between two vertically (or horizontally) consecutive lattice points and , which are separated by distance . Furthermore is at a horizontal (or vertical) distance strictly greater than from and . The widest angle the incoming and outgoing edges of can form is hence , effectively forming a turning angle of at least . As the sum of turning angles inside a convex is equal to and can never decrease, and as such a turning angle can only happen twice. Also, as in order to include any point outside of , has to go in between and , the width of this (possible non-contiguous region) including is at most and the diameter at most , hence, the area is bounded by . Therefore, there can be no more than two such regions in (even though each of them can enter and leave multiple times), which proves the lemma. ∎

Using lemma 5, it follows that . Lemma 4 gives us that . Lemma 6 gives us that . Hence

proving the following theorem.

Theorem 7.

Let be the area of the solution of Problem 7 with input polygon of diameter . Let be a parameter and , where is the erosion of by and is the lattice of size . The area of the convex hull of the solution of Problem 1 with input satisfies .

The polygon in the previous theorem may partially extend outside . Nevertheless, the solution of Problem 1 can be used to obtain a convex polygon which has an area satisfying .

The same proof strategy can be applied to obtain an approximation to the continuous version of the 2-potato-peeling problem using the digital version of the problem.

5 Conclusion and Open Problems

The (continuous) potato peeling problem is a very peculiar problem in computational geometry. The fastest algorithms known have running times that are polynomials of substantially high degree. Also, we are not aware of any algorithms (or difficulty results) for the natural extensions to higher dimensions (even 3d) or to a fixed number of convex bodies.

In this paper, we focused on a digital version of the problem. Many problems in the intersection of digital, convex, and computational geometry remain open. Our study falls in the following framework of problems, all of which receive as input a set of lattice points and are based on a fixed parameter .

  1. Is the union of at most digital convex sets?

  2. What is the smallest superset of that is the union of at most digital convex sets?

  3. What is the largest subset that is the union of at most digital convex sets?

In [CDG19], the authors considered the first problem for , presenting polynomial time solutions (which may still leave room for major improvements for ). We are not aware of any previous solutions for . In contrast, the continuous version of the problem is well studied. The case of can be solved easily by a convex hull computation or by linear programming. Polynomial algorithms are known for and  [Bel93, She93], as well as for and  [Bel95b]. The problem is already NP-complete for  [Bel95b]. Hence, the continuous version remains open only for and fixed .

It is easy to obtain polynomial time algorithms for the second problem when , since the solution consists of all points in the convex hull of . The continuous version for can be solved in time [BCES18]. Also, the orthogonal version of the problem is well studied (see for example [EGH16]). We know of no results for the digital version.

In this paper, we considered the digital version of the third problem for and , presenting algorithms with respective running times of and , where is the diameter of . Since the first problem trivially reduces to the third problem, we have also solved the first problem for in time. It is surprising that we are not aware of any faster algorithm for the first problem in this particular case. We note that our algorithms are presented in terms of maximizing the area, but they can easily be modified to maximize the number of lattice points in the solution.

The third problem for or remains open. The DAG approach that we used for is unlikely to generalize to higher dimensions, since there is no longer a single order by which to transverse the boundary of a convex polytope. Surprisingly, even the continuous version seems to be unresolved for or .

References

Comments 0
Request Comment
You are adding the first comment!
How to quickly get a good reply:
  • Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
  • Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
  • Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
""
The feedback must be of minimum 40 characters and the title a minimum of 5 characters
   
Add comment
Cancel
Loading ...
371299
This is a comment super asjknd jkasnjk adsnkj
Upvote
Downvote
""
The feedback must be of minumum 40 characters
The feedback must be of minumum 40 characters
Submit
Cancel

You are asking your first question!
How to quickly get a good answer:
  • Keep your question short and to the point
  • Check for grammar or spelling errors.
  • Phrase it like a question
Test
Test description