Elsevier

Computational Geometry

Volume 100, January 2022, 101820
Computational Geometry

Minimum rectilinear polygons for given angle sequences

https://doi.org/10.1016/j.comgeo.2021.101820Get rights and content

Abstract

A rectilinear polygon is a simple polygon whose edges are axis-aligned. Walking counterclockwise on the boundary of such a polygon yields a sequence of left turns and right turns. The number of left turns always equals the number of right turns plus four. It is known that any such sequence can be realized by a rectilinear polygon.

In this paper, we consider the problem of finding realizations that minimize the perimeter or the area of the polygon or the area of the bounding box of the polygon. We show that all three problems are NP -hard in general. This answers an open question of Patrignani (2001) [13], who showed that it is NP -hard to minimize the area of the bounding box of an orthogonal drawing of a given planar graph. We also show that realizing a polyline within a bounding box of minimum area (or within a fixed given rectangle) is NP -hard. Then we consider the special cases of x-monotone and xy-monotone rectilinear polygons. For these, we can optimize the three objectives efficiently.

Introduction

In this paper, we consider the problem of computing, for a given rectilinear angle sequence, a “small” rectilinear polygon that realizes the sequence. A rectilinear angle sequence S is a sequence of left (+90) turns, denoted by L, and right (90) turns, denoted by R. We write S=(s1,,sn){L,R}n, where n is the length of S. As we consider only rectilinear angle sequences, we usually drop the term “rectilinear.” A rectilinear polygon P realizes an angle sequence S if there is a counterclockwise (ccw) walk along the boundary of P such that the turns at the vertices of P, encountered during the walk, form the sequence S. The turn at a vertex v of P is a left or right turn if the interior angle at v is 90 (v is convex) or, respectively, 270 (v is reflex). We call the problem Minimum Rectilinear Polygon for Given Angle Sequence.

In order to measure the size of a polygon, we only consider polygons that lie on the integer grid. In this context, the area of a polygon P corresponds to the number of grid cells that lie in the interior of P. The bounding box of P is the smallest axis-parallel enclosing rectangle of P. The perimeter of P is the sum of the lengths of the edges of P. The task is, for a given angle sequence S, to find a simple4 polygon that realizes S and minimizes

  • (a)

    its bounding box (area),

  • (b)

    its area, or

  • (c)

    its perimeter.

Fig. 1 shows that, in general, the three criteria cannot be minimized simultaneously.

Obviously, the angle sequence of a polygon is unique (up to rotation), but the number of polygons that realize a given angle sequence is unbounded. The formula for the angle sum of a polygon implies that, in any angle sequence, n=2r+4, where n is the length of the sequence and r is the number of right turns [17]. In other words, the number of right turns is exactly four less than the number of left turns.

Related work  Bae et al. [2] considered, for a given angle sequence S, the polygon P(S) that realizes S and minimizes its area. Given a number n, let δ(n) be the smallest area of P(S) over all angle sequences S of length n, and let Δ(n) be the largest area of P(S) over all angle sequences S of length n. They showed

  • (i)

    δ(n)=n/21 if n4mod8, δ(n)=n/2 otherwise, and

  • (ii)

    Δ(n)=(n2)(n+4)/8 for any n with n4.

The result for Δ(n) tells us that any angle sequence S of length n can be realized by a polygon with area at most (n2)(n+4)/8.

Several authors have explored the problem of realizing a turn sequence. Culberson and Rawlins [6] and Hartley [11] described algorithms that, given a sequence of exterior angles summing up to 2π, construct a simple polygon realizing that angle sequence. Culberson and Rawlins' algorithm, when constrained to ±90 angles, produces polygons with no colinear edges, implying that any n-vertex polygon can be drawn with area approximately (n/21)2. However, as Bae et al. [2] showed, the bound is not tight. In his PhD thesis, Sack [15] introduced label sequences (which are equivalent to turn sequences) and, among others, developed a grammar for label sequences that can be realized as simple rectilinear polygons. Vijayan and Wigderson [17] considered the problem of drawing rectilinear graphs, of which rectilinear polygons are a special case, using an edge labeling that is equivalent to a turn sequence in the case of paths and cycles.

In graph drawing, the standard approach to drawing a graph of maximum degree 4 orthogonally (that is, with rectilinear edges) is the topology–shape–metrics approach of Tamassia [16]:

  • (1)

    Compute a planar(ized) embedding, that is, a circular order of edges around each vertex that admits a crossing-free drawing;

  • (2)

    compute an orthogonal representation, that is, an angle sequence for each edge and an angle for each vertex;

  • (3)

    compact the graph, that is, draw it inside a bounding box of minimum area.

Step (3) is NP-hard5 for planar graphs as shown by Patrignani [13]. For non-planar graphs, it is even inapproximable within a polynomial factor unless P=NP as shown by Bannister et al. [3]. Note that an orthogonal representation computed in step (2) is essentially an angle sequence for each face of the planarized embedding, so our problem corresponds to step (3) in the special case that the input graph is a simple cycle.

Another related problem is to reconstruct a simple (non-rectilinear) polygon from partial geometric information. Disser et al. [7] constructed a simple polygon in O(n3logn) time from an ordered sequence of angles measured at the vertices visible from each vertex. Chen and Wang [5] showed how to solve the problem in O(n2) time, which is optimal in the worst-case. Biedl et al. [4] considered polygon reconstruction from points (instead of angles) captured by laser scanning devices. Very recently, Asaeedi et al. [1] showed how to enclose a given set of points by a simple polygon whose vertices are a subset of the points and that optimizes some criteria (minimum area, maximum perimeter or maximum number of vertices). The vertex angles are constrained to lie below a threshold.

Our contribution  We show that finding a minimum polygon that realizes a given angle sequence is NP -hard for any of the three measures: area of the bounding box, polygon area, and polygon perimeter; see Section 2. This hardness result extends the one of Patrignani [13] and settles an open question that he posed. We note that in an extended abstract [8] of this paper there were some inaccuracies in our proof that now have been addressed. As a warm-up, we show that realizing an angle sequence as a polyline within a given rectangle is NP -hard. We then infer that it is also NP -hard to find a realizing polyline within a bounding box of minimum area.

We also give efficient algorithms for special types of angle sequences, namely xy- and x-monotone sequences, which are realized by xy-monotone and x-monotone polygons, respectively. For example, Fig. 1 shows that LLRRLLRLLRLRLLRLRLLR is an x-monotone sequence. Our algorithms for these angle sequences minimize the bounding box and the area (Section 3) and the perimeter (Section 4). For an overview of our results, see Table 1. Throughout this paper, a segment is always an axis-aligned line segment.

Section snippets

NP-hardness of the general case

In contrast to the special cases that we efficiently solve in later sections, the general case of our problem turns out to be NP -hard. In two steps, we show NP -hardness for all three objectives: minimizing the perimeter of the polygon, the area occupied by the polygon, and the area of the bounding box. First, in Section 2.2, we consider the base problem defined below from whose NP -hardness we then derive the three desired results in Section 2.2. As a warm-up, we show via a reduction from our

The monotone case: minimum area

In this section, we show how to compute, for a monotone angle sequence, a polygon of minimum bounding box and of minimum area. We start with the simple xy-monotone case and then consider the more general x-monotone case.

The monotone case: minimum perimeter

In this section, we show how to compute a polygon of minimum perimeter for any xy-monotone or x-monotone angle sequence S of length n.

Let P be an x-monotone polygon realizing S. Let eL be the leftmost vertical edge and let eR be the rightmost vertical edge of P. Recall that P consists of two x-monotone chains; an upper chain T and a lower chain B connected by eL and eR. For every eT, let T(eR,e) denote the subchain of T consisting of all segments between eR and e (without eR and e). Similarly,

Conclusion

In this paper, we considered the problem of drawing a polygon realizing a given angle sequence on a rectilinear grid such that its area, its bounding box, or its perimeter is minimized. We have seen several efficient algorithms for x-monotone and xy-monotone variants of the problem and have shown that the general variant is NP -hard for all three objectives. These results raise the question about the approximability of the general problem. Step by step, one could consider more and more

Declaration of Competing Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Acknowledgements

We thank Titto Patrignani for inspiring Theorem 1 and for informing us about the status of the compaction problem.

References (17)

There are more references available in the full text version of this article.

Cited by (0)

A preliminary version of this paper appeared in the Proceedings of the 18th Japan Conference on Discrete and Computational Geometry and Graphs (JCDCGG 2015) [8]. Note that this preliminary version had inaccuracies in the NP-hardness proof. Another version of this article is contained in the dissertation of K. Fleszar [9].

1

Supported by NSERC Discovery grant.

2

Supported by CONICYT grant PII 20150140 and by ERC consolidator grant TUgbOAT no. 772346.

3

Supported by NRF grant no. 2019R1F1A1058963 funded by the Korean government (MSIT).

View full text