Capturing points with a rotating polygon
(and a 3D extension)
We study the problem of rotating a simple polygon to contain the maximum number of elements from a given point set in the plane. We consider variations of this problem where the rotation center is a given point or lies on a line segment, a line, or a polygonal chain. We also solve an extension to 3D where we rotate a polyhedron around a given point to contain the maximum number of elements from a set of points in the space.
Keywords: Points covering, rotation, geometric optimization, polygon, polyhedron.
Given a simple polygon on the plane, the Polygon Placement Problem consists in finding a function , usually consisting of the composition of a rotation and a translation, such that satisfies some geometric constraints. In the literature, is known as a placement of . The oldest problem of this family who, given two polygons and , explored the problem of finding, if it exists, a placement of that contains . The most recent contribution to these problems, in 2014, can be found in  (see Section 1.4 there for a summary of previous work). Among other results, for a point set and a simple polygon , they show how to compute a placement of that contains as many points of as possible. If and are the sizes of and respectively, their algorithm runs in time and space.
Although translation-only problems have also been considered [1, 4], surprisingly enough there are no previous results with being only a rotation. It is important to note that existing results with being a composition of a rotation, a translation, and even a scaling, cannot be adapted to solve the rotation-only problem considered here: All those previous results reduce the search space complexity by considering only placements where a constant number of points from lie on the boundary of (see for example references  and  for algorithms based respectively, on two-point and one-point placements). Rotation-only adaptations of these results would not allow the rotation center to be fixed or restricted to lie on a given curve and therefore, cannot be applied to the problems we deal with in this paper. This is why the following Maximum Cover under Rotation (MCR) problems are considered in this paper:
Problem 1 (Fixed MCR).
Given a point , a polygon , and a point set in the plane, compute an angle such that, after clockwise rotating around by , the number of points of contained in is maximized.
Problem 2 (Segment-restricted MCR).
Given a line segment , a polygon , and a point set in the plane, find a point on and an angle such that, after a clockwise rotating of around by , the number of points of contained in is maximized.
In addition, we complete the scene opening a path towards the study of these problems in 3D, by presenting a three-dimensional version of Problem 1:
Problem 3 (3D Fixed MCR).
Given a point , a polyhedron , and a point set in , compute the azimuth and altitude giving the direction in the unit sphere such that, after rotating a polyhedron by taking the -axis to that direction, the number of points of contained in is maximized.
Applications of polygon placement problems include global localization of mobile robots, pattern matching, and geometric tolerance; see the references in . Rotation-only problems arise, e.g., in robot localization using a rotating camera , with applications to quality control of objects manufactured around an axis .
We first show that Problem 1 is 3SUM-hard, i.e., solving it in subquadratic time would imply an affirmative answer to the open question of whether a subquadratic time algorithm for 3SUM exists, which is unlikely . Then, we present two algorithms to solve Problem 1: The first one requires time and space, for and being the sizes of and , respectively. The second one takes time and space, for in being the number of certain events. We also describe an algorithm that solves Problem 2 in time and space. This algorithm can be easily extended to solve variations of Problem 2 where lies on a line or a polygonal chain. Furthermore, our techniques for Problem 1 can be extended to 3D to solve Problem 3 within the same time and space complexities as Problem 2.
2 Fixed MCR (Problem 1)
Given a point on the plane and a point , let be the circle with center and radius . If we rotate in the counterclockwise direction around , is the curve described by during a rotation of around . The endpoints of the circular arcs resulting from intersecting and determine the rotation angles where enters (in-event) and leaves (out-event) the polygon . In the worst case, the number of such events per element of is , see Figure 1. If we consider all the points in we could get events.
2.1 A 3SUM-hard reduction
We show next that Problem 1 is 3SUM-hard, by a reduction from the Segments Containing Points Problem that was proved to be 3SUM-hard in : Given a set of real numbers and a set of pairwise-disjoint intervals on the real line, is there a real number such that ?
The Fixed MCR problem is 3SUM-hard.
Let be an interval of the real line that contains the set of points, and the set of intervals of an instance of the Segments Containing Points Problem. Wrap on a circle whose perimeter has length at least twice the length of . This effectively maps the points in and the intervals in into a set of points and a set of intervals on .
Clearly, finding a translation (if it exists) of the elements of such that , is equivalent to finding a rotation of the set of points around the center of such that all of the elements of are mapped to points contained in the intervals of .
To finish our reduction, construct a polygon as shown in Figure 2. ∎
2.2 An algorithm
Intersect rotation circles. Given a fixed point , compute the intersection points of and , for all . Each of these points determines an angle of rotation of around when enters or leaves , see Figure 3. These angles, in turn, determine a set of intervals whose endpoints correspond to the rotation angles in which enters or leaves and, hence, specify the rotation angles on the unit circle for which belongs to , see again Figure 3. Let . The set of endpoints of the intervals in can be sorted in time.
Compute the angle of maximum coverage. Using standard techniques, we can now perform a sweep on the set as depicted in Figure 4.
During the sweeping process, we maintain the number of points of lying in . If an in-event or an out-event occurs, that number is increased or decreased by one, respectively. At the end of the sweeping process, we report the angular interval(s) where the number is maximized.
Since the complexity of our algorithm is dominated by Step 1, which takes time, we conclude the following result.
The Fixed MCR problem can be solved in time and space.
2.3 An output-sensitive algorithm
We now show that, performing a plane sweep using a sweeping circle centered at whose diameter increases continuously, it is possible to intersect and the set of rotation circles in a more efficient way. The idea is to maintain a list of the edges intersecting the sweeping-circle, ordered by appearance along the sweeping-circle. Using the same technique shown in Figure 3, the edges are labeled as defining in- or out- events. The algorithm is outlined next.
Normalize . In the following steps, we consider to have no edges intersecting any circle centered at more than once. This can be guaranteed by performing a preprocessing step on : For every edge of , let be the intersection point between the line containing and the line perpendicular to passing through . If belongs to the relative interior of , subdivide this edge into the edges and . In the worst case, each edge of gets subdivided into two parts. See Figure 5.
Process a vertex of . Sort first the vertices of and according to their distance from . This is the order in which an expanding sweeping circle centered at will reach them.
As the sweeping-circle increases in size, we stop at each vertex of . Each time this happens, the number of intersections of with the boundary of will increase or decrease by two. We can maintain and update the ordered list of edges intersected by , using a red-black tree, in logarithmic time. This enables us to calculate the intersections of in time proportional to their number. It suffices to walk along the ordered list of edges intersected by the sweeping-circle. Each time the sweeping circle reaches an element of , the number and order of intersections of the sweeping circle with the edges of remains unchanged. However, since the points of intersection change, we need to recalculate them each time we reach a point of or .
Compute the intervals sequence for each element of . We can now compute, within the same time complexity, the intervals in which intersects the interior of . Note that these intervals are not the elements of , they have to be rotated according to the position of with respect to .
Construct the events sequence. Since for each point in we have computed the corresponding sequence of sorted intervals , all we need to do is to merge these (at most ) sequences into a complete sequence of events.
The normalization process takes time. Sorting the points in and the vertices of by distance from takes and time, respectively. The ordered list of edges intersecting the sweep-line is maintained in an -size red-black tree, so we can process all the vertices of in time. On the other hand, processing all the points in takes time, where denotes the total number of in- and out-events in a Fixed MCR problem. Finally, merging the sequences of sorted intervals takes time. We then sweep the merged list of in time to obtain a solution to our problem. The total time complexity is . The space complexity is . We have thus proved:
The Fixed MCR problem can be solved in time and space.
3 Segment-restricted MCR (Problem 2)
Our approach to solve Problem 2 is to characterize, for each in , the intersection between the polygon and the rotation circle while the center of moves along a line segment from to . For simplicity, we assume that lies on the origin and on the positive -axis. For each edge of , we parameterize the intersection between and using a function , where is the -coordinate of (ranging from to the -coordinate of ) and is the counterclockwise angle swept by the ray until it coincides with the ray emanating from and passing through the current point of intersection of and (assume for the moment that there exists exactly one such point of intersection). See Figure 12.
Leaving the details for Section 3.4, we obtain the following expression of as a function of :
where , , and are polynomials of degrees , , and , respectively. The motion of along thus corresponds to a set of points for which hits the boundary of . For each point , these points form curves bounding a collection of simple regions in the - plane; each point of any such region corresponds to a rotation of , by a counterclockwise angle of size with respect to a rotation center at , for which belongs to . Note that each pair of such regions have disjoint interiors, whereas their boundaries may intersect at most at a common vertex due to the simplicity of .
3.1 Subdividing the Edges of the Polygon
We mentioned earlier that, for convenience, we subdivide the edges of the polygon about their points of intersection (if any) with the -axis; so, in the following, we assume that each edge has no points on either side of the -axis. We further subdivide the edges in order to simplify the computation of the angle in terms of the -coordinate of the rotation center as it moves along the segment .
Theoretical Framework. Let us consider that we process the point , and denote by the closed disk bounded by , where is a point in . In Figure 7, is taken to lie above the -axis where either (top figure) or (bottom figure). The cases where or where lies below the -axis are symmetric, whereas the case where lies on the -axis is similar (see figures 9 and 10). Moreover, let be the mirror image of with respect to the -axis; clearly, coincides with if lies on the -axis. Finally, let (, resp.) be the open halfplane to the left (right, resp.) of the line perpendicular to the -axis that passes through .
Then, it is useful to observe the following properties.
Let be a point, and let , , , and , for , be as defined above.
Consider any two points with . If the point lies on the -axis, then the circles intersect only at . If the point does not lie on the -axis, the circles intersect at and at ’s mirror image about the -axis, and the line segment belongs to both .
For every point in the interior of , there exists a unique circle centered on the -axis that passes from and and its center lies to the right of ;
for every point in , there exists a unique circle centered on the -axis that passes from and and its center lies to the left of .
for every point in the interior of , there exists a unique circle centered on the -axis that passes from and and its center lies to the left of ;
for every point in , there exists a unique circle centered on the -axis that passes from and and its center lies to the right of .
From the definition of the circles for all , belongs to each such circle.
Next, assume that lies on the -axis and suppose for contradiction that two circles with intersect at a point as well. Then, both would belong to the perpendicular bisector of the line segment ; thus, the perpendicular bisector should coincide with the -axis. Then, since lies on the -axis, would coincide with , in contradiction to the assumption that . Therefore, if lies on the -axis, any two circles with intersect only at .
Now, assume that does not lie on the -axis. Then, since is the mirror image of with respect to the -axis, the -axis is the perpendicular bisector of the segment . Thus, belongs to all the circles centered on the -axis that pass from . The fact that belongs to each of the disks , for all , follows from the fact that each disk is a convex set containing and .
Let be the point of intersection of with the line through and ; see Figure 6(left). The line is well defined since . In fact, (because belongs to ), and thus is not perpendicular to the -axis, which implies that the perpendicular bisector of the line segment intersects the -axis at a single point; this point of intersection is precisely the center of . Since the perpendicular bisector of the line segment is parallel to and lies to the right of (because is an interior point of ), it intersects the -axis at a single point to the right of ; is the center of the circle centered on the -axis that passes from and .
Now, consider , and let be the open halfplane that is tangent to the circle at and contains . If , then the line through and intersects at and at another point , and . Then, as above, the perpendicular bisector of intersects the -axis at , whereas the perpendicular bisector of is parallel and to the left of (since is an interior point of ), and thus intersects the -axis at a point to the left of ; see Figure 6(left). It is important to observe that the proof so far applies no matter whether lies on the -axis or not.
Next, let us consider the case in which ; this case is not possible if lies on the -axis since then . Then, the line through perpendicular to the tangent to the circle at intersects the -axis at . Since , the line perpendicular to the line through and is not parallel to the -axis and thus intersects the -axis at a single point . In fact, since the angle of the triangle with as vertices is larger than , is to the left of ; see Figure 6(right).
The results for points in the interior of and are obtained in a fashion left-to-right symmetric to the one we used in order to obtain the results for the points in the interior of and , respectively. ∎
Statement (ii) of Lemma 7 directly implies that the union of all the circles forms precisely the closure of the symmetric difference of the disks and centered at and , respectively (see Figure 7); note that any point in the interior of
lies on a circle with in the interior of , whereas no other point does so. Lemma 7(ii) also implies the following corollary.
For any with to the left of :
Suppose that a line segment intersects a circle , where , at points such that the line segment lies entirely in the closure of . Then, the segment is tangent to a circle for some and the point of tangency belongs to . Symmetrically, the same result holds if the segment lies entirely in the closure of .
We prove the propositions for the halfplane ; the proofs for are left-to-right symmetric.
Since is to the left of , Lemma 7(ii) implies that lies in the interior of . This in turn implies that (i) , i.e., , and (ii) since the disk is bounded by and since each such disk is a convex set; we have a proper subset relation because the points in do not belong to .
Below, we prove the statement for the case that lies entirely in the closure of ; the proof for the case that is left-to-right symmetric.
Since and , then ; let be a point infinitesimally to the right of . Then, according to statement (i), and , which together imply that ; note that at least one of (which belong to ) belongs to , for otherwise, either degenerates to a single point, in contradiction to the fact that , or with , in contradiction to the fact that lies entirely in the closure of . Since the rotation center moves continuously along there exists a point such that is a single point, i.e., the line segment is tangent to the circle ; moreover, since , the point of tangency belongs to the line segment . ∎
The Subdivision Procedure. Our subdivision procedure for the polygon edges while processing point works in two phases: in Phase 1, we ensure that each circle intersects each resulting sub-edge in at most one point; in Phase 2, we ensure that for each sub-edge either or implying that the value of is uniquely determined from the value of its cosine.
Phase 1: If an edge of the polygon does not intersect or if at least one of its endpoints belongs to , then we need not do anything, otherwise:
If does not intersect the interior of , then is tangent to at most two of the circles and we subdivide it at these points of tangency; see edges and in Figure 7.
If intersects the interior of , then it crosses . If intersects the segment , then we subdivide at its point of intersection with (see edge in Figure 7); if not, then the points of intersection of with the boundary of both belong to either or (see edge in Figure 7), in which case we subdivide at its closest point to or , respectively.
It is not difficult to see that if the edge has two points of intersection with a circle , these two points of intersection end up belonging to different parts of the subdivided edge.
After Phase 1 has been complete, we apply Phase 2 on the resulting sub-edges. Let and be points such that and are the midpoints of segments and , respectively; see Figure 8. Then, Phase 2 involves the following subdivision steps.
If a sub-edge intersects , we subdivide it at this point of intersection (in Figure 8, see sub-edges and sub-edge in the top figure).
Additionally, if the sub-edge is tangent to two circles, we subdivide it at its point of intersection with the line through perpendicular to the -axis (see sub-edges in Figure 8).
By taking into account that each of Phase 1 and Phase 2 may introduce at most two subdivision points on a polygon edge, we conclude that each edge ends up subdivided into at most sub-edges.
Finally, it is important to note that the above described edge subdivision is introduced precisely for the processing of the current point being processed; that is, for the next element of , we ignore the subdivision points introduced and start working again with the edges of the polygon (subdivided only about the -axis).
Correctness. Before proving Theorem 10 which establishes the correctness of the subdivision procedure, we show the following useful lemma.
Let be an element of the point set and be the mirror image of with respect to the -axis.
If the point is such that , then belongs to the line segment .
For any point such that , there is a point for which has the segment as its diameter.
First, assume that lies on the -axis. Then, . The assumption implies that , which in turn implies that ; see Figure 10. Thus, , i.e., . Now, consider the case that does not lie on the -axis. Let be the (vertical) projection of onto the -axis. Since , . The line defined by (note that ) is perpendicular to the -axis and let be its point of intersection with the line supporting . Since , we conclude that . Moreover, by its construction, the line segment is parallel to the -axis, and since , the similarity of the triangles with vertices and implies that . Thus, and hence .
Assume that lies on the -axis. Let with , and suppose without loss of generality that is to the left of (the case where is to the right of is symmetric). Then, the midpoint of lies in and it is the center of the unique circle passing through . Therefore, has as its diameter.
Now assume that does not lie on the -axis. Consider any point with . Let be the point of intersection of the line segment with the -axis ( exists because and , and hence and , lie on opposite sides of the -axis). Note that since . Then, by the similarity of the triangles and we have that ; i.e., the point is the midpoint of . Therefore, belongs to the perpendicular bisector of and in fact, it is the only point of intersection of such bisector and the -axis. Note that, since , the line passing through and (remember that ) is not perpendicular to the -axis. This implies that the center of any circle passing through coincides with , that is, is a diameter of . ∎
Lemma 9(ii) implies that for any point belonging to , the corresponding angle is equal to , where is the center of the circle passing from .
Now we are ready to prove Theorem 10 which establishes that the subdivision steps of Phases 1 and 2 achieve the set goals.
After the completion of Phase 1, no resulting sub-edge intersects any circle for some in more than one point.
After the completion of Phase 2, for any two points (lying on circles and , respectively) of each resulting sub-edge, the counterclockwise angles and either both belong to or both belong to .
Suppose for contradiction that there exists a sub-edge and a circle with that intersect in two points and . The point and its mirror image subdivide the circle into two arcs, and , the former to the left of the line through perpendicular to the -axis and the latter to the right (note that if lies on the -axis, one of these arcs degenerates into a single point). Then, should belong to the same arc; otherwise, would not lie on the -axis and the line segment would intersect the line segment , and thus the sub-edge would have been subdivided in Phase 1 about its point of intersection with . Suppose without loss of generality that belong to the arc . But then, no matter whether the segment intersects the interior of or not, we have a contradiction. In the former case, the sub-edge would have been subdivided in Phase 1 about the perpendicular projection of onto ; ’s projection onto belongs to and thus is an interior point of . In the latter case, the sub-edge would have been subdivided in Phase 1 about its point of tangency with a circle with ; this point of tangency belongs to as shown in Corollary 8(ii). Therefore, after Phase 1, no resulting sub-edge intersects any circle for some in more than one point.
Suppose without loss of generality that the point lies above or on the -axis and it holds that ; the case where it holds that is left-to-right symmetric (the corresponding angles are equal to minus the corresponding angles when ), whereas the case where lies below the -axis is top-down symmetric (in this case too, the corresponding angles are equal to minus the corresponding angles when lies above the -axis).
Let (, respectively) be the subsets of points in the closure of the symmetric difference that are on or to the left of the line through that is perpendicular to the -axis and are on or above (on or below, respectively) ; symmetrically, let (, respectively) be the subsets of points in the closure of the symmetric difference that are on or to the right of the line through that is perpendicular to the -axis and are on or above (on or below, respectively) ; see Figure 9 and Figure 10. Consider a point lying on a circle with . Since according to Lemma 9(ii), for any point , the segment is a diameter of the circle centered on the -axis and passing from , if , the counterclockwise angle belongs to . Similarly, if then , if then , and if then . Since no sub-edge resulting after Phase 2 contains points in more than one of the regions , the statement of the theorem follows. ∎
3.2 The Algorithm
We are now ready to outline our algorithm for Problem 2:
Subdivide the edges of polygon about the -axis.
Process each point . For each point , we subdivide each edge of polygon (resulting from the previous step) into sub-edges (see the edge subdivision process described earlier). Next, for each sub-edge, we compute the curve of the angle with respect to the -coordinate of the rotation center as it moves along (see Equation 1), and finally we form the regions bounded by these curves.
Construct and traverse the arrangement of all the regions. Using standard techniques, we construct the arrangement of all the regions of all the elements of . Next, we traverse the dual graph of the resulting arrangement looking for a sub-region of maximum depth; any point in this sub-region determines a position of and a rotation angle that constitute a solution to the problem.
3.3 Time and Space Complexity
Step 1 clearly takes time and space, resulting into at most sub-edges. The edge subdivision while processing a point in Step 2 takes time and space, producing sub-edges: For each sub-edge , time suffices to determine whether its endpoints belong to the disks and , and whether intersects the circles , the segment , or the line supporting , as well as to compute any points of intersection. Moreover, the centers of the circles , for , to which is tangent are precisely the points of intersection of the segment with the parabola that is equidistant from point and the line supporting . Then, processing yields curves bounding regions. Thus, processing all the points in in Step 2 takes a total of time and produces a set of regions bounded by curves in the - plane. From Step 1, we can show the following lemma:
Any two (-)-curves as in Equation 1 have at most points of intersection.
The idea is based on the fact that a polynomial of constant degree has a constant number of roots. In our case, we have a square root which needs to be squared in order to be removed. Let us consider the two (-)-curves
Since a point of intersection of these curves belongs to both of them, we have:
from which, by squaring twice to get rid of the square roots, we get
The last equality is a polynomial of degree at most and, thus, it has at most real roots for (it is important to note that the value of in any pair satisfying Equation 2 satisfies the polynomial in Equation 3.3, although the reverse does not necessarily hold, i.e., not every root of the polynomial satisfies Equation 2). Thus, if we substitute the real roots of the polynomial in Equation 3.3 into Equation 1, we get at most possible points of intersection, due to the operand. ∎
Hence, the total number of intersection points of all the curves is . Using standard techniques, in time the arrangement of all these regions can be computed, and the dual graph of the resulting arrangement can be traversed looking for a sub-region of maximum depth. Any point in this sub-region determines a position of the rotation center and a rotation angle that constitute a solution to the problem. The space complexity is . Then:
The Segment-restricted MCR problem can be solved in
time and space.
Note that Problem 2 can also be solved in time even when the rotation center is restricted to lie on a line : Compute the Voronoi diagram of , and apply the algorithm we just described to a segment of containing all the intersection points of and the Voronoi edges. Moreover, if we restrict the rotation center to lie on a polygonal chain with line segments, we can trivially obtain the optimal placement of using time. In both cases, the space complexity is .
3.4 Equation 1: expressing as a function of
In order to simplify the exposition leading to Equation 1, for each point in the plane other than the current rotation center , we define a corresponding angle with respect to . In particular, let be the set of points above the -axis or on the -axis and to the right of and let be the set of points below the -axis or on the -axis and to the left of (clearly, the sets