This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Maximum overlap area of a convex polyhedron and a convex polygon under translation

Hyuk Jun Kweon  and  Honglin Zhu
Abstract.

Let PP be a convex polyhedron and QQ be a convex polygon with nn vertices in total in three-dimensional space. We present a deterministic algorithm that finds a translation vector v3v\in\mathbb{R}^{3} maximizing the overlap area |P(Q+v)||P\cap(Q+v)| in O(nlog2n)O(n\log^{2}n) time. We then apply our algorithm to solve two related problems. We give an O(nlog3n)O(n\log^{3}n) time algorithm that finds the maximum overlap area of three convex polygons with nn vertices in total. We also give an O(nlog2n)O(n\log^{2}n) time algorithm that minimizes the symmetric difference of two convex polygons under scaling and translation.

1. Introduction

Shape matching is an important topic in computational geometry, with useful applications in areas such as computer graphics. In a typical problem of shape matching, we are supplied two or more shapes, and we want to determine how much the shapes resemble each other. More precisely, given a similarity measure and a set of allowed transformations, we want to transform the shapes to maximize their similarity measure.

There are many candidates for the similarity measure, such as the Hausdorff distance and the Fréchet distance between the boundaries of the shapes. We can also consider the area/volume of overlap or of symmetric difference. The advantage to these is that they are more robust against noise on the boundary of the shapes [deberg1996].

The maximum overlap problem of convex polytopes has been studied by many. In dimension 22, de Berg et al. [deberg1996] give an O(nlogn)O(n\log n) time algorithm for finding a translation maximizing the area of intersection of two convex polygons (where nn denotes the total number of vertices of the polygons). In dimension 33, Ahn et al. [ahn2008] give an O(n3log4n)O(n^{3}\log^{4}n) expected time algorithm finding the maximum overlap of two convex polyhedra under translation. For the same problem, Ahn et al. [ahn2013] present an algorithm that runs in O(nlog3.5n)O(n\log^{3.5}n) time with probability 1nO(1)1-n^{-O(1)} and an additive error. For d>3d>3, given two convex polytopes of dimension dd with nn facets in total, Ahn et al. [ahn2013] give an algorithm that finds the maximum overlap under translation in O(nd/2+1logdn)O(n^{\lfloor d/2\rfloor+1}\log^{d}n) time with probability 1nO(1)1-n^{O(1)} and an additive error.

In the plane, when all rigid motions are allowed, Ahn et al. [ahn2007] give an approximate algorithm that finds a rigid motion realizing at least 1ϵ1-\epsilon times the maximal overlap in O((1/ϵ)logn+(1/ϵ2)log(1/ϵ))O((1/\epsilon)\log n+(1/\epsilon^{2})\log(1/\epsilon)) time. In dimension 33, Ahn et al. [ahn2014] present an approximate algorithm that finds a rigid motion realizing at least 1ϵ1-\epsilon times the maximal overlap in O(ϵ3nlog3.5n)O(\epsilon^{-3}n\log^{3.5}n) with probability 1nO(1)1-n^{-O(1)}.

When considering the maximum overlap as a similarity measure, we obviously can only allow area/volume-preserving transformations. However, we may want to allow scaling as a transformation—two similar triangles are supposed to be very “similar,” though they may have different sizes. In this case, the area of symmetric difference is a better measure of similarity. Yon et al. [yon2016] give an algorithm minimizing the symmetric difference of two convex polygons under translation and scaling in O(nlog3n)O(n\log^{3}n) expected time.

Our results

While many have studied the matching problem for two convex polytopes of the same dimension, to our knowledge no one has examined the problem for polytopes of different dimensions or matching more than two polytopes.

The main result in this paper is a deterministic algorithm for the problem of matching a convex polyhedron and a convex polygon under translation in three-dimensional space.

{restatable}

theoremalgo Let PP be a convex polyhedron and QQ a convex polygon with nn vertices in total. We can find a vector v3v\in\mathbb{R}^{3} that maximizes the overlap area |P(Q+v)||P\cap(Q+v)| in O(nlog2n)O(n\log^{2}n) time.

We also present two applications of our algorithm to other problems in computational geometry. First, we give a deterministic algorithm for maximizing the overlap of three convex polygons under translations.

{restatable}

theoremthreepolys Let PP, QQ, RR be three convex polygons with nn vertices in total in the plane. We can find a pair of translations (vQ,vR)4(v_{Q},v_{R})\in\mathbb{R}^{4} that maximizes the overlap area |P(Q+vQ)(R+vR)||P\cap(Q+v_{Q})\cap(R+v_{R})| in O(nlog3n)O(n\log^{3}n) time.

We also give a deterministic O(nlog2n)O(n\log^{2}n) time algorithm for minimizing the symmetric difference of two convex polygons under a homothety (a translation and a scaling), which is an improvement to Yon et al.’s randomized algorithm [yon2016].

{restatable}

theoremsymmdiff Let PP and QQ be convex polygons with nn vertices in total. Then we can find a homothety φ\varphi that minimizes the area of symmetric difference |Pφ(Q)|+|φ(Q)P||P\setminus\varphi(Q)|+|\varphi(Q)\setminus P| in O(nlog2n)O(n\log^{2}n) time.

The main ingredient in the proof of Section 1 is a new technique we introduce which generalizes Megiddo’s prune-and-search [megiddo1984]. This allows us to efficiently prune among nn groups of mm parallel lines.

{restatable}

theorempruneandsearch Let S=i=1nSiS=\bigcup_{i=1}^{n}S_{i} be a union of nn sets of O(m)O(m) parallel lines in the plane, none of which are parallel to the xx-axis, and suppose the lines in each SiS_{i} are indexed from left to right.

Suppose there is an unknown point p2p^{*}\in\mathbb{R}^{2} and we are given an oracle that decides in time TT the relative position of pp^{*} to any line in the plane. Then we can find the relative position of pp^{*} to every line in SS in O(nlog2m+(T+n)log(mn))O(n\log^{2}m+(T+n)\log(mn)) time.

Organization of the Paper

In Section 2, we introduce the problem of matching a convex polyhedron and a convex polygon under translation in three-dimensional space. In Section 3, we present a core technique we use in our algorithm, which is a generalization of Megiddo’s prune-and-search technique [megiddo1984]. In Section 4, we present the algorithm for Section 1. In Section 5, we apply our algorithm to solve the problem of maximizing the intersection of three polygons under translation. In Section 6, we give the algorithm for minimizing the symmetric difference of two convex polygons under homothety.

Acknowledgements

This paper is the result of the MIT SPUR 2022, a summer undergraduate research program organized by the MIT math department. The authors would like to thank the faculty advisors David Jerison and Ankur Moitra for their support and the math department for providing this research opportunity. We thank the anonymous referees of SoCG 2023 for providing helpful comments that increased the quality of this paper.

2. Preliminaries

Let P3P\subset\mathbb{R}^{3} be a convex polyhedron and Q2Q\subset\mathbb{R}^{2} be a convex polygon with nn vertices in total. Throughout the paper, we assume that QQ is in the xyxy-plane, and that the point in PP with minimal zz coordinate is on the xyxy-plane. We want to find a translation vector v=(x,y,z)3v=(x,y,z)\in\mathbb{R}^{3} that maximizes the overlap area f(v)=|P(Q+v)|f(v)=|P\cap(Q+v)|.

It is easy to observe that f(v)f(v) is continuous and piecewise quadratic on the interior of its support. As noted in [deberg1996, ahn2008, ahn2013], ff is smooth on a region RR if P(Q+v)P\cap(Q+v) is combinatorially equivalent for all vRv\in R, that is, if we have the same set of face-edge incidences between PP and QQ. Following the convention of [ahn2008], we call the polygons that form the boundaries of these regions the event polygons, and as in [deberg1996], we call the space of translations of QQ the configuration space. The arrangement of the event polygons partition the configuration space into cells with disjoint interiors. The overlap function f(v)f(v) is quadratic on each cell. Thus, to locate a translation maximizing ff, we need to characterize the event polygons.

For two sets A,BdA,B\subset\mathbb{R}^{d}, we write the Minkowski sum of AA and BB as

A+B:={a+b|aA,bB}.A+B:=\{a+b|a\in A,b\in B\}.

We will make no distinction between the translation A+vA+v and the Minkowski sum A+{v}A+\{v\} for a vector vv. We also write ABA-B for the Minkowski sum of AA with B={b|bB}-B=\{-b|b\in B\}. We categorize the event polygons into three types and describe them in terms of Minkowski sums:

  1. (I)

    When Q+vQ+v contains a vertex of PP. For each vertex uu of PP, we have an event polygon uQu-Q. There are O(n)O(n) event polygons of this type.

  2. (II)

    When a vertex of Q+vQ+v is contained in a face of PP. For each face FF of PP and each vertex vv of QQ, we have an event polygon FvF-v. There are O(n2)O(n^{2}) event polygons of this type.

  3. (III)

    When an edge of Q+vQ+v intersects an edge of PP. For each edge ee of PP and each edge ee^{\prime} of QQ, we have an event polygon eee-e^{\prime}. There are O(n2)O(n^{2}) event polygons of this type.

The reason that convexity is fundamental is due to the following standard fact, as noted and proved in [deberg1996, yon2016].

Proposition 2.1.

Let PP be a dd^{\prime}-dimensional convex polytope and let QQ be a dd-dimensional convex polytope. Suppose ddd^{\prime}\geq d. Let f(v)=Vol(P(Q+v))f(v)=\operatorname{Vol}(P\cap(Q+v)) be the volume of the overlap function. Then, f(v)1/df(v)^{1/d} is concave on its support supp(f)={v|f(v)>0}\operatorname{supp}(f)=\{v|f(v)>0\}.

As in [avis1996], we say a function f:f:\mathbb{R}\to\mathbb{R} is unimodal if it increases to a maximum value, possibly stays there for some interval, and then decreases. It is strictly unimodal if it strictly increases to the maximum and then strictly decreases. Furthermore, we say a function f:df:\mathbb{R}^{d}\to\mathbb{R} is (strictly) unimodal if its restriction to any line is (strictly) unimodal.

The following corollary of Proposition 2.1 allows us to employ a divide-and-conquer strategy in our algorithm.

Corollary 2.2 ([avis1996]).

For any line ll parameterized by l=p+vtl=p+vt in d\mathbb{R}^{d^{\prime}} for v0v\neq 0, the function fl(t)=f(p+vt)f_{l}(t)=f(p+vt) is strictly unimodal.

We also use the following two techniques in our algorithm.

Lemma 2.3 ([frederickson1984]).

Let MM be an m×nm\times n matrix of real numbers, where mnm\leq n. If every row and every column of MM is in increasing order, then we say MM is a sorted matrix. For any positive integer kk smaller or equal to mnmn, the kk-th smallest entry of MM can be found in O(mlog(2n/m))O(m\log(2n/m)) time, assuming an entry of MM can be accessed in O(1)O(1) time.

For our purposes, we will use this result in the weaker form of O(m+n)O(m+n).

Lemma 2.4 ([chazelle1993]).

Given nn hyperplanes in d\mathbb{R}^{d} and a region RdR\subset\mathbb{R}^{d}, a (1/r)(1/r)-cutting is a collection of simplices with disjoint interiors, which together cover RR and such that the interior of each simplex intersects at most n/rn/r hyperplanes. A (1/r)(1/r)-cutting of size O(rd)O(r^{d}) can be computed deterministically in O(nrd1)O(nr^{d-1}) time. In addition, the set of hyperplanes intersecting each simplex of the cutting is reported in the same time.

3. Generalized two-dimensional prune-and-search

In this section, we prove Section 1, our generalization of Megiddo’s prune-and-search technique [megiddo1984]. This technique is of independent interest and can likely be applied to other problems.

In [megiddo1984], Megiddo proves the following:

Theorem 3.1 ([megiddo1984]).

Suppose there exists a point p2p^{*}\in\mathbb{R}^{2} not known to us. Suppose further that we have an oracle that can tell us for any line l2l\subset\mathbb{R}^{2} whether plp^{*}\in l, and if plp^{*}\notin l, the side of ll that pp^{*} belongs to. Let TT be the running time of the oracle. Then given nn lines in the plane, we can find the position of pp^{*} relative to each of the nn lines in O(n+Tlogn)O(n+T\log n) time.

We are interested in a generalized version of Megiddo’s problem. Suppose, instead of nn lines, we are given nn sets of parallel lines S1,S2,,SnS_{1},S_{2},\ldots,S_{n}, each of size O(m)O(m). In addition, suppose the lines in each SiS_{i} are indexed from left to right (assuming none of the lines are parallel to the xx-axis). Again, we want to know the position of pp^{*} relative to every line in S=i=1nSiS=\bigcup_{i=1}^{n}S_{i}. Megiddo’s algorithm solves this problem in O(mn+Tlog(mn))O(mn+T\log(mn)) time, but we want a faster algorithm for large mm by exploiting the structure of SS.

Without loss of generality, suppose that there are no lines parallel to the yy-axis. For each ii between 11 and nn, suppose Si={lij|lia lies strictly to the left of lib iff a<b}S_{i}=\{l_{i}^{j}|l_{i}^{a}\text{ lies strictly to the left of }l_{i}^{b}\text{ iff }a<b\}. Suppose that p=(x,y)2p^{*}=(x^{*},y^{*})\in\mathbb{R}^{2}. To report our final answer, we simply need to provide, for each SiS_{i}, the two consecutive indices aa and a+1a+1 such that pp^{*} lies strictly between lial_{i}^{a} and lia+1l_{i}^{a+1} or the single index aa such that pliap^{*}\in l_{i}^{a}.

In our algorithm, we keep track of a feasible region RR containing PP^{*}, which is either the interior of a (possibly unbounded) triangle or an open line segment if we find a line ll that pp^{*} lies on. Together with RR, we keep track of the 2n2n indices lower(i)\operatorname{lower}(i) and upper(i)\operatorname{upper}(i) such that SR=i=1nSiR={lij|j(lower(i),upper(i)]}S^{R}=\bigcup_{i=1}^{n}S_{i}^{R}=\{l_{i}^{j}|j\in(\operatorname{lower}(i),\operatorname{upper}(i)]\} is the set of lines intersecting RR, which is also the set of lines we do not yet know the relative position to pp^{*}. In the beginning, R=2R=\mathbb{R}^{2}. Each step, we find O(1)O(1) lines to run the oracle on to find a new feasible region RRR^{\prime}\subset R such that |SR|17/18|SR||S^{R}|\leq 17/18|S^{R^{\prime}}| and recurse on RR^{\prime}. An outline is given in Algorithm 3.1.

input : A set S=i=1nSi={lij}S=\bigcup_{i=1}^{n}S_{i}=\{l_{i}^{j}\} of O(mn)O(mn) lines
output : A list of indices that indicate the position of pp^{*} to each SiS_{i}
1 R2R\longleftarrow\mathbb{R}^{2}
2 SRSS^{R}\longleftarrow S
3 while |SR|18|S^{R}|\geq 18 do
4       Find O(1)O(1) lines to run the oracle on
5       Compute the piece RRR^{\prime}\subset R containing pp^{*}
       /* We guarantee that RR^{\prime} intersects at most 17/1817/18 of the lines that intersect RR */
6       Triangulate RR^{\prime} with O(1)O(1) lines to run the oracle on
7       Update SRSRS^{R}\longleftarrow S^{R^{\prime}}
8 end while
9Compute relative position of pp^{*} to the remaining lines by brute force
Algorithm 3.1 Pseudocode for Section 1

One extra computational effort is updating SRS^{R^{\prime}} by computing lower(i)\operatorname{lower}(i) and upper(i)\operatorname{upper}(i). Since the feasible region is always a convex set of constant complexity, we can use binary search on SiRS_{i}^{R} to find the new bounds for SiRS_{i}^{R^{\prime}} in O(log|SiR|)O(\log|S_{i}^{R}|) time. Thus, the total time involved in this process, assuming |SR||S^{R}| decreases by at least ϵ=1/18\epsilon=1/18 each iteration, is

i=1nO(log|Si|)+i=1nO(log|SiR1|)+i=1nO(log|SiR2|)+\displaystyle\sum_{i=1}^{n}O(\log|S_{i}|)+\sum_{i=1}^{n}O(\log|S_{i}^{R_{1}}|)+\sum_{i=1}^{n}O(\log|S_{i}^{R_{2}}|)+\cdots
=\displaystyle= O(nlog(1n|S|))+O(nlog(1n|SR1|))+O(nlog(1n|SR2|))+\displaystyle O(n\log(\frac{1}{n}|S|))+O(n\log(\frac{1}{n}|S^{R_{1}}|))+O(n\log(\frac{1}{n}|S^{R_{2}}|))+\cdots
=\displaystyle= O(nlog(m))+O(nlog(m(1ϵ)))+O(nlog(m(1ϵ)2))+\displaystyle O(n\log(m))+O(n\log(m(1-\epsilon)))+O(n\log(m(1-\epsilon)^{2}))+\cdots
=\displaystyle= O(nlog2m).\displaystyle O(n\log^{2}m).

We will use the following well-known result:

Lemma 3.2 ([cormen2009]).

Suppose we are given nn distinct real numbers with positive weights that sum to 11. Then we can find the weighted median of these numbers in O(n)O(n) time.

Given SRS^{R} and RR, we want to find RRR^{\prime}\subset R to recurse on.

Lemma 3.3.

If |SR|18|S^{R}|\geq 18, then in O(T+n)O(T+n) time, we can find a region RRR^{\prime}\subset R of constant complexity containing pp^{*} so that its interior intersects no more than 17/1817/18 of all the lines in SRS^{R}.

Proof 3.4.

For convenience, we write SR=S=i=1nSi={lij}S^{R}=S=\bigcup_{i=1}^{n}S_{i}=\{l_{i}^{j}\}. We first find the weighted median of the slopes of the lines in SS, where the slope of the lines of SiS_{i} is weighted by |Si|/|S||S_{i}|/|S|. This can be done in O(n)O(n) time by Lemma 3.2.

If this slope is equal to the slope of some line in SiS_{i} and |Si|19|S||S_{i}|\geq\frac{1}{9}|S|, then we can simply divide the plane using the median line of SiS_{i} and the xx-axis and the interior of each quadrant will avoid at least 1/181/18 of the lines of SS.

Otherwise, at least 4/94/9 of the lines have slopes strictly greater than/less than the median slope. Without loss of generality, we assume at least 4/94/9 of the lines have positive slope and at least 4/94/9 of the lines have negative slope. Now let S+=i=1kSiS_{+}=\bigcup_{i=1}^{k}S_{i} and S=i=k+1nSiS_{-}=\bigcup_{i=k+1}^{n}S_{i} denote the set of lines with postive/negative slope, respectively. We remove lines from the larger of the two sets until they have the same size.

S1S_{1}S2S_{2}S3S_{3}S4S_{4}
Figure 1. P1P_{1}, P2P_{2} are P3P_{3} are represented by colors.

We partition S+SS_{+}\cup S_{-} into O(n)O(n) subsets PiP_{i} each containing the same number of lines from S+S_{+} and SS_{-} in the following way: going in lexicographical order by the indices of the lines, we put a line from S1S_{1} and a line from Sk+1S_{k+1} into P1P_{1} until we exhaust one of the sets (say it is Sk+1S_{k+1}). Then, we move on to put a line from the remaining S1S_{1} and a line from Sk+2S_{k+2} into P2P_{2} until we exhaust one of them, and so on. Each PiP_{i} is then of the form {la(i)b(i),,la(i)b(i)+|Pi|/21,lc(i)d(i),,lc(i)d(i)+|Pi|/21}\{l_{a(i)}^{b(i)},\ldots,l_{a(i)}^{b(i)+|P_{i}|/2-1},l_{c(i)}^{d(i)},\ldots,l_{c(i)}^{d(i)+|P_{i}|/2-1}\}, and can be represented by the indices (a(i),b(i))(a(i),b(i)) and (c(i),d(i))(c(i),d(i)) (see Figure 1). We can compute this partition in O(n)O(n) time. For each PiP_{i}, we compute the intersection pi=(xi,yi)p_{i}=(x_{i},y_{i}) of the median line in PiP_{i} with positive slope and the median line with negative slope, and assign pip_{i} a weight wi=|Pi|/(2|S+|)w_{i}=|P_{i}|/(2|S_{+}|). Then, the weights of the pip_{i} sum to 11. The significance of this is that if we know the relative position of pp^{*} to the lines x=xix=x_{i} and y=yiy=y_{i}, then we know the relative position of pp^{*} to at least 1/41/4 of the lines in PiP_{i}, which is at least 29wi\frac{2}{9}w_{i} of all the lines in |S||S|.

We find the median point q=(xq,yq)q=(x_{q},y_{q}) of the pip_{i}’s by weight in xx-coordinate in O(n)O(n) time by Lemma 3.2. We run the oracle on the line x=xqx=x_{q}. Let pk1,pk2,,pklp_{k_{1}},p_{k_{2}},\ldots,p_{k_{l}} be the points such that we now know the relative position of pp^{*} to xkix_{k_{i}}. Then the weights of these points sum to at least 1/21/2. We find the median point q=(xq,yq)q^{\prime}=(x_{q^{\prime}},y_{q^{\prime}}) of these by weight in yy-coordinate in O(n)O(n) time. We run the oracle on the line y=yqy=y_{q^{\prime}}. Then, for points with weights that sum to at least 1/41/4, we now know the relative position of pp^{*} to the vertical line and the horizontal line through those points. This means that we know the relative position of pp^{*} to at least 2914=118\frac{2}{9}\cdot\frac{1}{4}=\frac{1}{18} of all the lines in |S||S|. We get a new feasible region according to the two oracle calls whose interior avoids at least 1/181/18 of the lines in SS, and we triangulate it with O(1)O(1) more oracle calls to get our desired region, in O(T+n)O(T+n) time total.

Proof 3.5 (Proof of Section 1).

After O(logmn)O(\log mn) recursive iterations of Lemma 3.3, we arrive at a feasible region intersecting at most 1717 lines in SS, and we can finish by brute force. Therefore, our algorithm runs in O(nlog2m+(T+n)log(mn))O(n\log^{2}m+(T+n)\log(mn)) time.

Remark 3.6.

A simpler and probably more practical algorithm for Lemma 3.3 is simply choosing a random line from S+S_{+} and SS_{-} to intersect and run the oracle on the horizontal and vertical line through the intersection. This method gives the same run time in expectation.

4. Maximum overlap of convex polyhedron and convex polygon

In section, we give the algorithm that finds a translation v3v\in\mathbb{R}^{3} maximizing the area of overlap function ff. Following the convention in [deberg1996], we call such a translation a goal placement. In the algorithm, we keep track of a closed target region RR which we know contains a goal placement and decrease its size until for each event polygon FF, either Finterior(R)=F\cap\operatorname{interior}(R)=\varnothing or FRF\supset R. Then, ff is quadratic on RR and we can find the maximum of ff on RR using standard calculus. Thus, the goal of our algorithm is to efficiently trim RR to eliminate event polygons that intersect it.

In the beginning of the algorithm, the target region is the interior of the Minkowski sum PQP-Q, where the overlap function is positive. By the unimodality of the overlap function, the set of goal placements is convex. Thus, for a plane in the configuration space, either it contains a goal placement, or all goal placements lie on one of the two open half spaces separated by the plane. If we have a way of knowing which case it is for any plane, we can decrease the size of our target region by cutting it with planes and finding the piece to recurse. More precisely, we need a subroutine PlaneDecision that decides the relative position of the set of goal placements to a plane SS.

Whenever PlaneDecision reports that a goal placement is found on a plane, we can let the algorithm terminate. Thus, we can assume it always reports a half-space containing a goal placement.

As in Algorithm 4.1, we break down our algorithm into three stages.

input : A convex polyhedron P3P\in\mathbb{R}^{3} and a convex polygon Q3Q\in\mathbb{R}^{3} with nn vertices in total
output : A translation v3v\in\mathbb{R}^{3} maximizing the area |P(Q+v)||P\cap(Q+v)|
1 Locate a horizontal slice containing a goal placement that does not contain any vertices of PP and replace PP by this slice of PP
2 Find a “tube” D+lyD+l_{y} whose interior contains a goal placement and intersects O(n)O(n) event polygons, where DD is a triangle in the xzxz-plane and lyl_{y} is the yy-axis
3 Recursively construct a (1/2)(1/2)-cutting of the target region D+lyD+l_{y} to find a simplex containing a goal placement that does not intersect any event polygon
Algorithm 4.1 Pseudocode for Section 1

4.1. Stage 1

In the first stage of our algorithm, we make use of [deberg1996] to simplify our problem so that PP can be taken as a convex polyhedron with all of its vertices on two horizontal planes.

We sort the vertices of PP by zz-coordinate in increasing order and sort the vertices of QQ in counterclockwise order. Next, we trim the target region with horizontal planes (planes parallel to the xyxy-plane) to get to a slice that does not contain any vertices of PP.

Lemma 4.1.

In O(nlog2n)O(n\log^{2}n) time, we can locate a strip R={(x,y,z)|z[z0,z1]}R=\{(x,y,z)|z\in[z_{0},z_{1}]\} whose interior contains a goal placement and PP has no vertices with z[z0,z1]z\in[z_{0},z_{1}].

Figure 2. The slice of PP with z[z0,z1]z\in[z_{0},z_{1}].
Proof 4.2.

Starting with the median zz-coordinate of the vertices of PP, we perform a binary search on the levels containing a vertex of PP. For a horizontal plane SS, [deberg1996, Theorem 3.8] allows us to compute the maximum overlap of PSP\cap S and QQ under translation in O(nlogn)O(n\log n)-time. The two planes S1S_{1} and S2S_{2} with the largest maximum values will be the bounding planes for the slice containing a goal placement by the unimodality of ff. Thus, by a binary search, we can locate this slice in O(nlog2n)O(n\log^{2}n) time.

By Chazelle’s algorithm [chazelle1992], the convex polyhedron P={(x,y,z)P|z[z0,z1]}P^{\prime}=\{(x,y,z)\in P|z\in[z_{0},z_{1}]\} can be computed in O(n)O(n) time. From now on, we replace PP with PP^{\prime} (see Figure 2). Without loss of generality, assume z0=0z_{0}=0 and z1=1z_{1}=1.

The region in the configuration space where |P(Q+v)|>0|P\cap(Q+v)|>0 is the Minkowski sum PQP-Q. Since PP only has two levels P0={(x,y,z)P|z=0}P_{0}=\{(x,y,z)\in P|z=0\} and P1={(x,y,z)P|z=1}P_{1}=\{(x,y,z)\in P|z=1\} that contain vertices, the Minkowski sum PQP-Q is simply the convex hull of (P0Q)(P1Q)(P_{0}-Q)\cup(P_{1}-Q), which has O(n)O(n) vertices. We can compute P0QP_{0}-Q and P1QP_{1}-Q in O(n)O(n) time and compute their convex hull in O(nlogn)O(n\log n) time by Chazelle’s algorithm [chazelle1993b].

4.2. PlaneDecision

With the simplification of the problem in Stage 11, we now show that the subroutine PlaneDecision can be performed in O(nlogn)O(n\log n) time. Let SS be a fixed plane in the configuration space. We call a translation vv that achieves maxvSf(v)\operatorname{max}_{v\in S}f(v) a good placement. First, we can compute the intersection of SS with PQP-Q in O(n)O(n) time by Chazelle’s algorithm [chazelle1992]. If the intersection is empty, we just report the side of SS containing PQP-Q. From now on assume this is not the case.

The following lemma shows that PlaneDecision runs in the same time bound as the algorithm that just finds the maximum of ff on a plane.

Lemma 4.3.

Suppose we can compute maxvSf(v)\operatorname{max}_{v\in S}f(v) for any plane S3S\subset\mathbb{R}^{3} in time TT, then we can perform PlaneDecision for any plane in time O(T)O(T).

Proof 4.4.

The idea is to compute maxvSf(v)\operatorname{max}_{v\in S^{\prime}}f(v) for certain SS^{\prime} that are perturbed slightly from SS to see in which direction relative to SS does ff increase.

We compute over an extension of the reals [ω]/(ω3)\mathbb{R}[\omega]/(\omega^{3}), where ω>0\omega>0 is smaller than any real number. Let A>0A>0 be the maximum of ff over a plane SS. Let S+S_{+} and SS_{-} be the two planes parallel to SS that have distance ω\omega from SS. We compute A+=maxvS+f(v)A_{+}=\operatorname{max}_{v\in S_{+}}f(v) and A=maxvSf(v)A_{-}=\operatorname{max}_{v\in S_{-}}f(v) in O(T)O(T) time. Since ff is piecewise quadratic, A+A_{+} and AA_{-} as symbolic expression will only involve quadratic terms in ω\omega. Since ff is strictly unimodal on PQP-Q, there are three possibilities:

  1. (1)

    If A+>AA_{+}>A, then halfspace on the side of S+S_{+} contains the set of goal placements.

  2. (2)

    If A>AA_{-}>A, then halfspace on the side of SS_{-} contains the set of goal placements.

  3. (3)

    If AA+A\geq A_{+} and AAA\geq A_{-}, then AA is the global maximum of ff.

Thus, in O(T)O(T) time, we can finish PlaneDecision.

Finding a good placement on SS is similar to finding a goal placement on the whole configuration space. SS is partitioned into cells by the intersections of event polygons with SS. We need to find a region on SS containing a good placement that does not intersect any event polygons.

We present a subroutine LineDecision that finds, for a line lSl\subset S, the relative position of the set of good placements on SS to ll.

Proposition 4.5.

For a line lSl\subset S, we can perform LineDecision in O(n)O(n) time.

PPQ+lQ+l
Figure 3. The convex polyhedron II is formed by interesecting PP and (Q+l)(Q+l).
Proof 4.6.

First, we compute maxvlf(v)\operatorname{max}_{v\in l}f(v) and a vector achieving the maximum. We parameterize the line ll by p+vtp+vt where tt is the parameter and p,v3p,v\in\mathbb{R}^{3}. The horizontal cross-section of I=P(Q+l)I=P\cap(Q+l) at height tt has area f(p+vt)f(p+vt). Since II is the intersection of two convex polytopes with O(n)O(n) vertices (see Figure 3), Chazelle’s algorithm [chazelle1992] computes II in O(n)O(n) time. Then, [avis1996, Theorem 3.2] computes the maximum cross-section in O(n)O(n) time.

Now, by the same argument and method as in the proof of Lemma 4.3, we can finish LineDecision in O(n)O(n) time. In the case where maxvlf(v)=0\operatorname{max}_{v\in l}f(v)=0, we report the side of ll containing S(PQ)S\cap(P-Q).

Whenever our subroutine LineDecision reports a good placement is found on a line, we can let the algorithm terminate. Thus, we can assume it always reports a half-plane of SS containing a good placement.

We now present PlaneDecision. If SS is horizontal, then we only need to find the maximum overlap of the convex polygons PSP\cap S and QQ using De Berg et al.’s algorithm [deberg1996], which takes O(nlogn)O(n\log n) time. Thus, we assume SS is non-horizontal.

input : A plane S3S\subset\mathbb{R}^{3}
output : A translation vSv\in S maximizing the area |P(Q+v)||P\cap(Q+v)|
1 Compute S(PQ)S\cap(P-Q) and set it to be our initial target region.
2 Locate a strip on SS containing a good placement whose interior intersects O(n)O(n) event polygons.
3 Recursively construct a (1/2)(1/2)-cutting of the strip to find a triangle containing a good placement that does not intersect any event polygon
Algorithm 4.2 Pseudocode for PlaneDecision

As in Algorithm 4.2, we break down PlaneDecision into three steps. We have already explained Step 11, where we compute S(PQ)S\cap(P-Q), so we begin with Step 22.

4.2.1. PlaneDecision: Step 2

We want to find a strip on SS strictly between z=0z=0 and z=1z=1 that intersects O(n)O(n) event polygons. Since there are no vertices of PP with zz-coordinate in the interval (0,1)(0,1), there are no event polygons of type (I) in this range, and we will only need to consider event polygons of type (II) and type (III).

We look at the intersection points of SS with the edges of the event polygons. These edges come from the set {eivj|ei non-horizontal edge of P,vj vertex of Q}\{e_{i}-v_{j}|e_{i}\text{ non-horizontal edge of }P,\,v_{j}\text{ vertex of }Q\}. Without loss of generality, assume that SS is parallel to the yy-axis. We are interested in the zz-coordinates of the intersections, so we project everything into the xzxz-plane. Then, SS becomes a line, which we denote by lSl_{S}, and each edge eivje_{i}-v_{j} becomes a segment whose endpoints lie on z=0z=0 and z=1z=1. Suppose each edge eie_{i} projects to a segment sis_{i}, and each vjv_{j} projects to a point xjx_{j} on the xx-axis. Then, we get O(n2)O(n^{2}) segments sixjs_{i}-x_{j} with endpoints on z=0z=0 and z=1z=1, and the line lSl_{S} that intersect them in some places.

Lemma 4.7.

In O(nlogn)O(n\log n) time, we can locate a strip R={(x,y,z)S|z[z0,z1]}R=\{(x,y,z)\in S|z\in[z_{0},z_{1}]\} whose interior contains a good placement and intersects none of the edges of the event polygons.

Proof 4.8.

By our setup, we want to find a segment on lSl_{S} whose interior does not intersect any segment of the form sixjs_{i}-x_{j}.

Since sis_{i} are projections of edges of a convex polyhedron, we can separate them into two sets such that edges from the same set do not intersect (we take the segments that are projections of the edges of the “front” side and “back” side, respectively), allowing the two extremal edges to appear in both sets. We will process each set separately. This can be done by identifying the extremal points points on the top and bottom faces of PP in the xx direction, which can be done in O(logn)O(\log n) time.

For a set of non-intersecting segments, since they all have endpoints on the line z=0z=0 and z=1z=1, we can sort them by the sum of the xx-coordinates of their two endpoints. This takes O(nlogn)O(n\log n) time. We further separate these segments into two sets by slope: those that make a smaller angle than lSl_{S} with the positive xx-axis, and those that make a larger angle.

Suppose we now have a set of non-intersecting segments that all make larger angles than lSl_{S} with the positive xx-axis, s1,s2,,sms_{1},s_{2},\ldots,s_{m}, where m=O(n)m=O(n). We also sort the projections of the vertices of QQ, x1,,xqx_{1},\ldots,x_{q}, in decreasing order by xx-coordinate. This can be done in O(logn)O(\log n) time by identifying the extremal vertices of QQ in the xx-direction.

Let zijz_{ij} be the zz-coordinate of the intersection of the line containing sixjs_{i}-x_{j} with lSl_{S}. Let MM be an m×qm\times q matrix with (i,j)(i,j)-th entry given by

Mij={0zij0zijzij(0,1)1zij1.M_{ij}=\begin{cases}0&z_{ij}\leq 0\\ z_{ij}&z_{ij}\in(0,1)\\ 1&z_{ij}\geq 1\end{cases}.

We claim that MM is a sorted matrix. To see this, consider any fixed row rr and indices i<ji<j. Then the line containing srxis_{r}-x_{i} lies strictly to the left of the line containing srxjs_{r}-x_{j} since xi>xjx_{i}>x_{j}. This means that zri<zrjz_{ri}<z_{rj}. Thus, every row of MM is in increasing order. Similarly, for a fixed column cc and indices i<ji<j, the segment sixcs_{i}-x_{c} lies strictly to the left of the segment sjxcs_{j}-x_{c}. Then, if they both intersect lSl_{S}, we must have zic<zjcz_{ic}<z_{jc}. If sixcs_{i}-x_{c} does not intersect lSl_{S} and sjxcs_{j}-x_{c} does, then sixcs_{i}-x_{c} must lie on the left of lSl_{S} and thus Mic=a<zjc=MjcM_{ic}=a<z_{jc}=M_{jc}. Similarly, if sixcs_{i}-x_{c} intersects lSl_{S} and sjxcs_{j}-x_{c} does not, then sjxcs_{j}-x_{c} must lie on the right of lSl_{S} and thus Mic=zic<b=MjcM_{ic}=z_{ic}<b=M_{jc}. If they both do not intersect lSl_{S}, then still MicMjcM_{ic}\leq M_{jc} since it is impossible to have Mic=bM_{ic}=b and Mjc=aM_{jc}=a. This proves our claim.

By Lemma 2.3, we can find the kk-th smallest value in MM in O(m+q)=O(n)O(m+q)=O(n) time. Thus, we can perform a binary search on these zz-coordinates of the intersections of the edges eivje_{i}-v_{j} with SS. Each time we perform a LineDecision on the line with the median zz-coordinate of the remaining entries to eliminate half of the intersections. After O(logn)O(\log n) iterations or O(nlogn)O(n\log n) time, we find a strip on SS containing a good placement that contains no intersections with this group of edges.

We repeat the same procedure for the other three groups and compute the intersection of the four strips to find a strip containing a good placement that contains no intersections with any edge of the event polygons.

Figure 4. Projecting the configuration space onto the xzxz-plane. The projection of SS is the magenta line segment, and the projection of the strip RR obtained form Lemma 4.7 is the cyan line segment.

Our current target region, the strip RR we obtained from Lemma 4.7 (see Figure 4), intersects few event polygons and we can compute them efficiently.

Lemma 4.9.

The interior of the region RR intersects O(n)O(n) event polygons, and we can compute them in O(nlogn)O(n\log n) time.

Proof 4.10.

For a vertex vv of QQ, it contributes the O(n)O(n) event polygons of type (II) that are the faces of PvP-v. The intersection of the boundary of PvP-v with SS is a convex polygon. Since there are no intersections with edges of event polygons inside the strip RR, at most two edges of the convex polygon can lie inside RR, one on the “front side” and the other on the “back side.”

To compute these two segments on RR, we first consider the two sorted matrices given in the proof of Lemma 4.7 that together describe the edges on the “front side” and look at the column associated to v-v. We find, for each column, the two (or zero) adjacent entries that contain the zz-coordinates of RR in between. The two of the at most four that are closest to the strip will be the endpoints of the segment that intersect the strip on the “front side.” Computing this segment takes O(logn)O(\log n) time since we can use binary search on the columns to find the desired entries. We do the same to find the segment on the “back side.” We do this for all vertices of QQ to find the O(n)O(n) intersections with the event polygons of type (II) in O(nlogn)O(n\log n) time.

For an edge ee of PP, it contributes O(n)O(n) event polygons of type (III) that form the surrounding sides of a “cylinder” with base congruent to Q-Q. Again, each of these “cylinders” intersect the strip RR in at most two faces, so there are O(n)O(n) intersections of RR with event polygons of type (III). We can compute these segments by performing the binary search on the row of one of the sorted matrices associated to the edge ee. The two entries immediately below the strip and the two immediately above the strip define the at most two segments intersecting RR. Similar to the procedure above, this takes O(logn)O(\log n) time for each edge of PP, thus O(nlogn)O(n\log n) time in total.

4.2.2. PlaneDecision: Step 3

Now, we have a target region RR and the O(n)O(n) intersections it makes with the event polygons.

Lemma 4.11.

In O(nlogn)O(n\log n) time, we can find a region RRR^{\prime}\subset R containing a good placement that does not intersect any of the O(n)O(n) event polygons.

Proof 4.12.

We recursively construct a (1/2)(1/2)-cutting of the target region. By Lemma 2.4, a (1/2)(1/2)-cutting of constant size can be computed in O(n)O(n) time. We perform LineDecision on the lines of the cutting to decide on which triangle to recurse. After O(logn)O(\log n) iterations, we have a target region RR^{\prime} that intersects no event polygons. This procedure runs in O(nlogn)O(n\log n) time.

Finally, since the overlap function is quadratic on our final region RR^{\prime}, we can solve for the maximum using standard calculus. After finding maxvSf(v)\operatorname{max}_{v\in S}f(v) and a vector achieving it O(nlogn)O(n\log n) time, by Lemma 4.3, we can perform PlaneDecision on SS in the same time bound.

Proposition 4.13.

For a plane SS, we can perform PlaneDecision in O(nlogn)O(n\log n) time.

4.3. Stage 2

With the general PlaneDecision at our disposal, we now move on to State 22, the main component of our algorithm. We project the entire configuration space and the event polygons onto the xzxz-plane in order to find a target region DD whose preimage D+lyD+l_{y} intersects few event polygons, where lyl_{y} is the yy-axis (see Figure 5).

(a) Projection of PP(b) Projection of QQ(c) Projection of the configuration space, and the target region DD
Figure 5. Projecting onto the xz-plane.

The non-horizontal edges of the event polygons project to segments on the strip 0<z<10<z<1 on the xzxz-plane. We characterize our desired region DD in the following lemma.

Lemma 4.14.

For a region DD that does not intersect any of the segments that are the projections of the non-horizontal edges of the event polygons, the preimage D+lyD+l_{y} intersects O(n)O(n) event polygons.

Proof 4.15.

For any region DD on the xzxz-plane, the set of event polygons that the “tube” D+lyD+l_{y} intersects is precisely the set of projected event polygons that DD intersects. Now, let DD be a region that does not intersect any segment from the projections of the event polygons.

Let s1,s2,,sms_{1},s_{2},\ldots,s_{m} be the segments that are the projections of the non-horizontal edges of PP, and let x1,,xqx_{1},\ldots,x_{q} be the projections of the vertices of QQ on the xx-axis and assume that they are sorted by decreasing xx-coordinate. Then, the projections of the non-horizontal edges of the event polygons are precisely sixjs_{i}-x_{j}.

We first split the segments into four groups. Let s1,,sm1s_{1},\ldots,s_{m_{1}} be the projections of the non-horizontal edges of PP on the “front side,” and sm1+1,,sms_{m_{1}+1},\ldots,s_{m} be those on the “back side.” The at most two edges visible on both the front and the back may be repeated. Then the segments from either group are pairwise non-intersecting. Similarly, we split the vertices of QQ into a front side and a backside, including the at most two vertices visible on both the front and back in both sets. We consider the segments in the configuration space made by one of the two groups of edges of PP and one of the two groups of vertices of QQ. The other three sets of segments are processed similarly.

Suppose that the segments we consider are s1,,sm1s_{1},\ldots,s_{m_{1}}, and the projected vertices are x1,,xq1x_{1},\ldots,x_{q_{1}}. Suppose the segments are sorted by increasing sum of the xx-coordinates of their endpoints, and that the vertices are sorted by decreasing xx-coordinate. The event polygons of type (II) are the trapezoids or triangles between segments sixjs_{i}-x_{j} and si+1xjs_{i+1}-x_{j} for each of the four groups of segments. For each fixed projected vertex xx, the region DD intersects at most one event polygon of type (II) for each group. Thus, DD intersects O(n)O(n) event polygons of type (II). Similarly, the event polygons of type (III) are the parallelograms between segments sixjs_{i}-x_{j} and sixj+1s_{i}-x_{j+1} for each of the four groups of segments. For each fixed segment sis_{i}, DD intersects at most one event polygon of type (III), thus it intersects O(n)O(n) event polygons of type (III) in total.

Now it remains to efficiently find such a region DD with D+lyD+l_{y} containing a goal placement and compute the O(n)O(n) event polygons that intersect its interior.

Lemma 4.16.

In O(nlog2n)O(n\log^{2}n) time, we can find a triangle DD in the xzxz-plane such that the interior of D+lyD+l_{y} contains a goal placement and intersects O(n)O(n) event polygons. We can compute these O(n)O(n) event polygons in the same time bound.

Proof 4.17.

The computation of DD is a direct application of Section 1, where m=O(n)m=O(n). Calling the oracle on a line ll in the xzxz-plane is running the PlaneDecision algorithm on the plane parallel to the yy-axis that projects to ll. We compute a triangle for each of the four groups of segments, take their intersection, and triangulate the intersection using O(1)O(1) calls to PlaneDecision. Thus, we can compute the desired triangle DD in O(nlog2n)O(n\log^{2}n) time.

To compute the event polygons intersecting the interior of D+lyD+l_{y} is simple, since we have shown in the proof of Lemma 4.14 that DD intersects at most one projection of an event polygon of each type in each of the four groups for a fixed vertex xjx_{j} (for type (II)) or segment sis_{i} (for type (III)). Once we have DD, we can compute these polygons by binary search on each of the O(n)O(n) groups of O(n)O(n) non-intersecting segments to find the two between which RR lies. Also, the event polygons all have constant complexity so computing all of them takes linear time. We can recover the event polygons from their projections and compute the planes that contain them in linear time. Thus, this entire process can be done in O(nlogn)O(n\log n) time.

4.4. Stage 3

Now, we have a target region R=D+lyR=D+l_{y} whose interior contains a goal placement, and we have the O(n)O(n) event polygons that intersect it.

Lemma 4.18.

In O(nlog2n)O(n\log^{2}n) time, we can find a region RRR^{\prime}\subset R containing a goal placement that does not intersect any of the O(n)O(n) event polygons.

Proof 4.19.

We recursively construct a (1/2)(1/2)-cutting of the target region. By Lemma 2.4, a (1/2)(1/2)-cutting of constant size can be computed in O(n)O(n) time. We perform PlaneDecision on the planes of the cutting to decide on which simplex to recurse. After O(logn)O(\log n) iterations, we have a target region RR^{\prime} that intersects no event polygons. This procedure runs in O(nlog2n)O(n\log^{2}n) time.

Finally, since the overlap function is quadratic on our final region RR^{\prime}, we can solve for the maximum using standard calculus. This concludes the proof of Section 1.

5. Maximum overlap of three convex polygons

Let PP, QQ, RR be three convex polygons with nn vertices in total in the plane. We want to find a pair of translations (vQ,vR)4(v_{Q},v_{R})\in\mathbb{R}^{4} that maximizes the overlap area g(vQ,vR)=|P(Q+vQ)(R+vR)|g(v_{Q},v_{R})=|P\cap(Q+v_{Q})\cap(R+v_{R})|.

In this problem, the configuration space is four-dimensional. An easy extension of Proposition 2.1 and Corollary 2.2 shows that the function of overlap area is again unimodal. This time, we have four-dimensional event polyhedra instead of event polygons that divide the configuration space into four-dimensional cells on which g(vQ,vR)g(v_{Q},v_{R}) is quadratic. We call a hyperplane containing an event polyhedron an event hyperplane, and they are defined by two types of events:

  1. (I)

    When one vertex of PP, Q+vQQ+v_{Q} or R+vRR+v_{R} lies on an edge of another polygon. There are O(n)O(n) groups of O(n)O(n) parallel event hyperplanes of this type.

  2. (II)

    When an edge from each of the three polygons intersect at one point. There are O(n3)O(n^{3}) event hyperplanes of this type.

To overcome the difficulty of dealing with the O(n3)O(n^{3}) event hyperplanes of type (II), we first prune the configuration space to a region intersecting no event hyperplanes of type (I). We then show that the resulting region only intersects O(n)O(n) event hyperplanes of type (II).

Similar to Section 1, we want an algorithm HyperplaneDecision that computes, for a hyperplane H4H\subset\mathbb{R}^{4}, the maximum max(vQ,vR)Hg(vQ,vR)\operatorname{max}_{(v_{Q},v_{R})\in H}g(v_{Q},v_{R}) and the relative location of the goal placement to HH. In fact, we will only need to perform HyperplaneDecision on some hyperplanes.

Proposition 5.1.

Suppose HH is a hyperplane that satisfies one of the following three conditions:

  1. (1)

    HH is orthogonal to a vector (x1,y1,0,0)(x_{1},y_{1},0,0) for some x1,y1x_{1},y_{1}\in\mathbb{R}.

  2. (2)

    HH is orthogonal to a vector (0,0,x2,y2)(0,0,x_{2},y_{2}) for some x2,y2x_{2},y_{2}\in\mathbb{R}.

  3. (3)

    HH is orthogonal to a vector (x1,y1,x1,y1)(x_{1},y_{1},-x_{1},-y_{1}) for some x1,y1x_{1},y_{1}\in\mathbb{R}.

Then, we can perform HyperplaneDecision on HH in O(nlog2n)O(n\log^{2}n) time.

Proof 5.2.

We provide the algorithm for HH orthogonal to (x1,y1,0,0)(x_{1},y_{1},0,0) for some x1,y1x_{1},y_{1}\in\mathbb{R}, and the other two types follow similarly.

We reinterpret the problem of finding max(vQ,vR)Hg(vQ,vR)\operatorname{max}_{(v_{Q},v_{R})\in H}g(v_{Q},v_{R}) as a polyhedron-polygon matching problem. In HH, we allow RR to move freely, and QQ moves in a line ll perpendicular to (x1,y1)(x_{1},y_{1}). We parameterize ll by l=p+vtl=p+vt, and form the convex polyhedron (see Figure 6)

IPQ={(x,y,t)|(x,y)P}{(x,y,t)|(x,y)(Q+p+vt)}.I_{PQ}=\{(x,y,t)|(x,y)\in P\}\cap\{(x,y,t)|(x,y)\in(Q+p+vt)\}.

By [chazelle1992], II can be computed in O(n)O(n) time. In addition, the cross-section of II at t=t0t=t_{0} is P(Q+p+vt)P\cap(Q+p+vt). Then, we see that finding max(vQ,vR)Hg(vQ,vR)\operatorname{max}_{(v_{Q},v_{R})\in H}g(v_{Q},v_{R}) is the same as finding a translation maximizing the intersection of II and RR. By Section 1, this can be done in O(nlog2n)O(n\log^{2}n) time.

Using the formal perturbation argument in Lemma 4.3, HyperplaneDecision on HH can be completed in the same time bound.

P+(z-axis)P+\text{($z$-axis)}Q+lQ+l
Figure 6. The convex polyhedron IPQI_{PQ} is the intersection of these two objects.

Using Proposition 5.1, we can prune the configuration space to a region that intersects no event hyperplanes of type (I) and O(n)O(n) event hyperplanes of type (II).

Proposition 5.3.

We can compute a 4-polytope TPQRT_{PQR} of complexity O(1)O(1) in O(nlog3n)O(n\log^{3}n) time such that

  1. (1)

    the goal placement lies on TPQRT_{PQR},

  2. (2)

    no hyperplane of type (I) intersects the interior of TPQRT_{PQR}, and

  3. (3)

    only O(n)O(n) event polyhedrons of type (II) passes through TPQRT_{PQR}.

The hyperplanes of type (II) intersecting the interior of TPQRT_{PQR} are obtained in the same time bound. Furthermore, the 3-tuples of edges of PP, QQ and RR defining the hyperplanes are also obtained in the same time bound.

Proof 5.4.

If a HyperplaneDecision reports a goal placement, we are done. Thus, we assume that HyperplaneDecision always reports a halfspace containing a goal placement.

Each event hyperplane containing an event polyhedron of a vertex of PP on an edge of Q+vQQ+v_{Q} or an event polyhedron of a vertex of Q+vQQ+v_{Q} on an edge of PP is orthogonal to some (x1,y1,0,0)(x_{1},y_{1},0,0). We project all these event hyperplanes into the 22-flat SPQ={(x1,y1,0,0)|x1,y1}S_{PQ}=\{(x_{1},y_{1},0,0)|x_{1},y_{1}\in\mathbb{R}\}. Then, the images are O(n)O(n) groups of O(n)O(n) parallel lines. We can therefore apply Section 1 to these lines, where an oracle call on a line ll is running HyperplaneDecision on the hyperplane that projects to ll on SPQS_{PQ}, which is orthogonal to some (x1,y1,0,0)(x_{1},y_{1},0,0). Thus, by Proposition 5.1, we can find a triangle TPQSPQT_{PQ}\subset S_{PQ} whose interior does not intersect any event hyperplane as described above in O(nlog3n)O(n\log^{3}n) time.

Similarly, we can find the triangles

TPR{(0,0,x2,y2)|x2,y2}andTQR{(x1,y1,x1,y1)|x1,y1}T_{PR}\subset\{(0,0,x_{2},y_{2})|x_{2},y_{2}\in\mathbb{R}\}\quad\text{and}\quad T_{QR}\subset\{(x_{1},y_{1},-x_{1},-y_{1})|x_{1},y_{1}\in\mathbb{R}\}

corresponding to the other event hyperplanes of type (I) in O(nlog3n)O(n\log^{3}n) time. Then, the interior of

TPQR={(x1,y1,x2,y2)|\displaystyle T_{PQR}=\{(x_{1},y_{1},x_{2},y_{2})| (x1,y1,0,0)TPQ,(0,0,x2,y2)TPR,\displaystyle(x_{1},y_{1},0,0)\in T_{PQ},\,(0,0,x_{2},y_{2})\in T_{PR},\,
(x1x22,y1y22,x2x12,y2y12)TQR}\displaystyle\left(\frac{x_{1}-x_{2}}{2},\frac{y_{1}-y_{2}}{2},\frac{x_{2}-x_{1}}{2},\frac{y_{2}-y_{1}}{2}\right)\in T_{QR}\}

does not intersect any event hyperplane of type (I) and contains a goal placement.

Since the interior of TPQRT_{PQR} intersects no event hyperplane of type (I), the pairwise configuration of PP and QQ, PP and RR, QQ and RR are fixed (the pairwise edge incidences are fixed). Since any edge ePe_{P} of PP intersects at most two edges of QQ and at most two edges of RR inside TPQRT_{PQR}, there are at most four event hyperplanes of type (II) where ePe_{P} is concurrent with an edge of QQ and an edge of RR. Thus, at most 4n4n event hyperplanes of type (II) intersect the interior of TPQRT_{PQR}.

In the rest of the section, we fix TPQRT_{PQR} as in Proposition 5.3. Moreover, let

f(vP,vQ)={|P(Q+vQ)(R+vR)|if (vQ,vR)TPQR0otherwise.f(v_{P},v_{Q})=\begin{cases}|P\cap(Q+v_{Q})\cap(R+v_{R})|&\text{if }(v_{Q},v_{R})\in T_{PQR}\\ 0&\text{otherwise.}\end{cases}
Proposition 5.5.

Let SS be any mm-flat in the configuration space. In O(n)O(n) time, we can find a point in SsuppfS\cap\mathrm{supp\,}f, or report that SsuppfS\cap\mathrm{supp\,}f is empty.

Proof 5.6.

Notice that suppf\mathrm{supp\,}f is a convex 4-polytope whose face are hyperplanes of type I or type II. Let HH be a hyperplane of type II intersecting the interior of TPQRT_{PQR}. Then HH contains a face of suppf\mathrm{supp\,}f if and only if a polygon PQP\cap Q is tangent to RR in HTPQRH\cap T_{PQR}. This can be tested in constant time, so we can find all faces of suppf\mathrm{supp\,}f in O(n)O(n) time. Our problem become a feasibility test of a linear programming of size O(n)O(n), which can be solved in O(n)O(n) time by Megiddo’s algorithm [megiddo1984].

Proof 5.7 (Proof of Section 1).

Take TPQRT_{PQR} as in Proposition 5.3. Let

f(vP,vQ)={|P(Q+vQ)(R+vR)|if (vQ,vR)TPQR0otherwise.f(v_{P},v_{Q})=\begin{cases}|P\cap(Q+v_{Q})\cap(R+v_{R})|&\text{if }(v_{Q},v_{R})\in T_{PQR}\\ 0&\text{otherwise.}\end{cases}

Then ff is unimodal and the maximum of ff is the goal placement. Given an mm-flat SS, we want to compute the maximum of ff on SS in O(nlogm1)O(n\log^{m-1}) time by induction on m{1,2,3,4}m\in\{1,2,3,4\}.

If m=1m=1, this can be done in O(n)O(n) time by Proposition 4.5. Assume that m>1m>1. Then STPQRS\cap T_{PQR} can be computed in O(1)O(1) time. Given an (m1)(m-1)-flat lSl\subset S, we can use Proposition 5.5 and the perturbation method as in Lemma 4.3 to report the relative position of the maximum over SS. There are O(n)O(n) event hyperplane intersecting STPQRS\cap T_{PQR}. Thus, by Lemma 2.4, we can recursively construct (1/2)(1/2)-cuttings to give an O(nlogm1)O(n\log^{m-1}) time algorithm to find the maximum of ff on SS.

6. Minimum symmetric difference of two convex polygons under homothety

A homothety φ:22\varphi\colon\mathbb{R}^{2}\rightarrow\mathbb{R}^{2} is a composition of a scaling and a translation. Let λ>0\lambda>0 be the scaling factor and vv be the translation vector of φ\varphi. Then

φ(A)=λA+v={λp+vpA}.\varphi(A)=\lambda A+v=\{\lambda p+v\mid p\in A\}.

Define the symmetric difference of sets A,B2A,B\subset\mathbb{R}^{2} to be

AB:=\displaystyle A\triangle B:= (AB)(AB)\displaystyle(A\cup B)\setminus(A\cap B)
=\displaystyle= (AB)(BA).\displaystyle(A\setminus B)\cup(B\setminus A).

Let PP and QQ be convex polygons with nn vertices in total. We want to find a homothety φ\varphi of QQ that minimizes the area of symmetric difference

h(φ)=h(x,y,λ)=|Pφ(Q)|,h(\varphi)=h(x,y,\lambda)=|P\triangle\varphi(Q)|,

where φ(Q)=λQ+(x,y)\varphi(Q)=\lambda Q+(x,y).

Yon et al. [yon2016] consider a slightly more general problem, where they minimize the function

h(φ)=(22κ)|Pφ(Q)|+2κ|φ(Q)P|,h(\varphi)=(2-2\kappa)|P\setminus\varphi(Q)|+2\kappa|\varphi(Q)\setminus P|,

where κ(0,1)\kappa\in(0,1) is some constant. When κ=1/2\kappa=1/2, this is the area of symmetric difference function. They give a randomized algorithm that solves this problem in O(nlog3n)O(n\log^{3}n) expected time. We present a faster determinisitc algorithm by relating this problem to the polyhedron-polygon matching problem and then applying a modified version of Section 1.

As in [yon2016], we rewrite the objective function h(φ)h(\varphi):

h(φ)\displaystyle h(\varphi) =2(1κ)|P|+2κ|φ(Q)|2|Pφ(Q)|\displaystyle=2(1-\kappa)|P|+2\kappa|\varphi(Q)|-2|P\cap\varphi(Q)|
=2(1κ)|P|+2κ|Q|λ22|Pφ(Q)|.\displaystyle=2(1-\kappa)|P|+2\kappa|Q|\lambda^{2}-2|P\cap\varphi(Q)|.
QQCC
Figure 7. Formation of the cone CC.

Thus, minimizing h(φ)h(\varphi) is the same as maximizing f(φ)=|Pφ(Q)|cλ2f(\varphi)=|P\cap\varphi(Q)|-c\lambda^{2}, where c=κ|Q|c=\kappa|Q|. Consider the cone C={(x,y,λ)|λ[0,M],(x,y)λQ}C=\{(x,y,\lambda)|\lambda\in[0,M],(x,y)\in\lambda Q\}, where M=|P|/cM=\sqrt{|P|/c} (see Figure 7). Then ff is negative for λ>M\lambda>M so it is never maximized. We also put PP into 3\mathbb{R}^{3} by P={(x,y,0)|(x,y)P}P=\{(x,y,0)|(x,y)\in P\}. Since f(x,y,λ)=|C(P+(x,y,λ))|cλ2f(x,y,\lambda)=|C\cap(P+(-x,-y,\lambda))|-c\lambda^{2}, the problem reduces to maximizing the overlap area of the cone CC and PP under translation subtracted by a quadratic function. To show that we can still use a divide-and-conquer strategy, we identify a region where ff is strictly unimodal.

Lemma 6.1 ([yon2016]).

The closure 𝒟\mathcal{D} of the set {φ3|f(φ)>0}\{\varphi\in\mathbb{R}^{3}|f(\varphi)>0\} is convex. Furthermore, f(x,y,λ)f(x,y,\lambda) is strictly unimodal on 𝒟\mathcal{D}.

Proof 6.2.

This follows from [yon2016, Lemma 2.2] and [yon2016, Lemma 2.7].

Although it is difficult to directly compute 𝒟\mathcal{D}, note that P𝒟-P\subset\mathcal{D}. With this observation, we show that we can still find the relative position of the set of goal placements to certain planes SS in O(nlogn)O(n\log n) time with some modifications to LineDecision and PlaneDecision.

Lemma 6.3.

For any l3l\subset\mathbb{R}^{3}, we can compute maxφlf(φ)\operatorname{max}_{\varphi\in l}f(\varphi) or report it is a negative number in O(n)O(n) time.

Proof 6.4.

If ll is horizontal, then we can apply Proposition 4.5 since cλc\lambda is constant. Otherwise, we parameterize ll by l=p+vtl=p+vt and construct the convex polyhedron II whose cross-section I(t0)I(t_{0}) at t=t0t=t_{0} has area |C(P+(p+vt0))||C\cap(P+(p+vt_{0}))| as in the proof of Proposition 4.5. It comes down to maximizing |I(t)|c(λ(t))2|I(t)|-c(\lambda(t))^{2}, where λ(t)\lambda(t) is the λ\lambda-coordinate of p+vtp+vt. Since |I(t)|\sqrt{|I(t)|} is a concave function, |I(t)|cλ(t)\sqrt{|I(t)|}-\sqrt{c}\lambda(t) is also concave, and has the same complexity as |I(t)|\sqrt{|I(t)|}. Thus, we can apply [avis1996, Theorem 3.2] to find the maximum of |I(t)|cλ(t)\sqrt{|I(t)|}-\sqrt{c}\lambda(t). Supposed it is achieved at tt^{\prime}. Although tt^{\prime} may not be where the maximum of |I(t)|c(λ(t))2|I(t)|-c(\lambda(t))^{2} is, it tells us whether the maximum is positive. If not, we can simply terminate the process. If it is, we know that ll intersects 𝒟\mathcal{D}, and p+vt𝒟p+vt^{\prime}\in\mathcal{D}. This allows us to use divide-and-conquer as in [avis1996], since we can recurse in the direction of tt^{\prime} whenever we query a point tt and find f(t)<0f(t)<0.

Proposition 6.5.

Let S3S\subset\mathbb{R}^{3} be a plane. If SS is horizontal or if SS intersects the polygon P𝒟-P\subset\mathcal{D}, then we can perform PlaneDecision on SS in O(nlogn)O(n\log n) time.

Proof 6.6.

If SS is horizontal, then we can apply Algorithm 4.2. If the maximum is negative, then we simply report the side of SS containing P-P, otherwise we proceed as in Lemma 4.3.

Now assume SS is non-horizontal and intersects P-P. Let s=S(P)s=S\cap(-P). Then we know that s𝒟s\subset\mathcal{D}. Let lSl\subset S be a line we want to run the subroutine LineDecision on. By Lemma 6.3, we can find maxφlf(φ)\operatorname{max}_{\varphi\in l}f(\varphi) or report it is negative in O(n)O(n) time. If it is the latter case, we report the side of ll containing ss. Otherwise, ll intersects 𝒟\mathcal{D}, and we can proceed as in Lemma 4.3. Thus, we can still find maxφSf(φ)\operatorname{max}_{\varphi\in S}f(\varphi) in O(nlogn)O(n\log n) time. Since SS intersects 𝒟\mathcal{D}, we can use Lemma 4.3 to complete PlaneDecision on SS.

Theorem 6.7.

Let PP and QQ be convex polygons with nn vertices in total. Suppose κ(0,1)\kappa\in(0,1) is a constant. We can find a homothety φ\varphi that minimizes

h(φ)=2(1κ)|Pφ(Q)|+2κ|φ(Q)P|h(\varphi)=2(1-\kappa)|P\setminus\varphi(Q)|+2\kappa|\varphi(Q)\setminus P|

in O(nlog2n)O(n\log^{2}n) time.

Proof 6.8.

We want to maximize f(x,y,λ)=|C(P+(x,y,λ))|cλ2f(x,y,\lambda)=|C\cap(P+(-x,-y,\lambda))|-c\lambda^{2} over 3\mathbb{R}^{3}, where c=κ|Q|c=\kappa|Q|. In order to apply our algorithm for Section 1, we need to show that we only run PlaneDecision on horizontal planes and planes that intersect P-P.

In the first stage (as outlined in Algorithm 4.1), we only run PlaneDecision on horizontal planes.

In the second stage, we apply Section 1 to the O(n)O(n) groups of O(n)O(n) lines that are the projections of the lines containing edges of event polygons on the xzxz-plane. Observe that these lines all intersect the projection of P-P on the xzxz-plane. In each recursive step of our algorithm, we query a horizontal (parallel to the xx-axis) line and a line that goes “between” two lines in the O(n2)O(n^{2}) lines. The planes they represent both satisfy the condition for Proposition 6.5. Then we run PlaneDecision O(1)O(1) more times to triangulate our feasible region. Here, we make a small modification: instead of maintaining a triangular feasible region, we maintain a trapezoidal one by making O(1)O(1) horizontal cuts to make the region a trapezoid.

In the third stage, we have a “tube” and O(n)O(n) event polygons that intersect it. As usual, we recursively construct a (1/2)(1/2)-cutting by Lemma 2.4. Chazelle’s algorithm [chazelle1993] picks O(1)O(1) planes intersecting the target region as the cutting, along with O(1)O(1) extra planes to triangulate each piece. All the planes containing the event polygons intersect P-P, so we can run PlaneDecision on them. Instead of triangulating our target region, it suffices to reduce it to constant complexity. We do this by cutting it with O(1)O(1) horizontal planes such that the remaining region only has vertices on two levels. Then, let ee be any non-horizontal edge. With O(1)O(1) planes through ee, we can cut the target region into prisms and pyramids with triangular bases. These planes all intersect P-P since they are between the two faces of the target region containing ee, and the planes containing them intersect P-P.

Therefore, with slight modifications to Section 1, we obtain a deterministic O(nlog2n)O(n\log^{2}n) algorithm for minimizing h(φ)h(\varphi).

Section 1 follows as a direct corollary of Theorem 6.7.