Rotating Calipers

 

Some history:

In 1978, M.I. Shamos's Ph.D. thesis "Computational Geometry" marks the "birth" of the field within Computer Science. Among the results he presents is a very simple algorithm for finding the diameter of a convex polygon, i.e. the greatest distance determined a pair of points belonging to the polygon.
The diameter turns out to be determined by an
anti-podal pair of points. Shamos provides a simple O(n) time algorithm for determining the anti-podal pairs of a convex n-gon. Since there are at most 3n/2 of these, the diameter can then be found in O(n) time.
As Toussaint later put it, Shamos' algorithm resembles rotating a pair of calipers around the polygon. Thus the term "Rotating Calipers". In 1983, Toussaint presents a paper in which a variety of problems are solved using the same technique. Since then, new algorithms based on the paradigm have been obtained, solving a multitude of problems.

They include:


 

Thesis

My Master's Thesis, Computational Geometry with the Rotating Calipers (in Postscript format) gathers the above problems, while providing details and proofs. The bibliography is available here for viewing.

Applet

To use the Rotating Calipers and solve many of the above problems yourself, go to the Rotating Calipers applet page.

 

The diameter of a convex polygon

The diameter of a polygon is defined as the maximum distance between any two points of the polygon. It is possible for more than one pair of points to determine the diameter. In fact, if the polygon has n vertices, as many as n "diameter pairs" may exist.

A simple example of a polygon's diameter is illustrated to the left. The diameter pair, shown as black dots admits parallel lines of support (shown in red). The diameter is highlighted in light blue.


Obviously, the pair of points determining the diameter of a convex polygon P does not belong to the interior of P. The search should concentrate on the boundary. In fact, only anti-podal pairs of points should be checked, for the diameter is the greatest distance between parallel lines of support. Shamos (1978) provides a simple algorithm computing the anti-podal pairs of a convex n-gon in O(n) time. The diameter can then obtained by going through the list, and outputting the pair with maximum distance. The following is the pseudo-code for Shamos' algorithm, as presented in the text by Preparata and Shamos (1985).
The input is a polygon P={p1,...,pn}.

begin     p0:=pn;     q:=NEXT[p];     while (Area(p,NEXT[p],NEXT[q]) > Area(p,NEXT[p],q)) do          q:=NEXT[q];          q0:=q;          while (q != p0) do               begin                    p:=NEXT[p];                    Print(p,q);                    while (Area(p,NEXT[p],NEXT[q]) > Area(p,NEXT[p],q) do                         begin                              q:=NEXT[q];                              if ((p,q) != (q0,p0)) then Print(p,q)                              else return                         end;                    if (Area(p,NEXT[p],NEXT[q]) = Area(p,NEXT[p],q)) then                      if ((p,q) != (q0,p0)) then Print(p,NEXT[q])                      else Print(NEXT[p],q)               endend.


Note that Print(p,q) signifies the output of (p,q) as an anti-podal pair and Area(p,q,r) signifies the signed-area of triangle pqr.
Although this procedure is not as intuitive as the usual Rotating Calipers algorithm, it is essentially the same, and avoids any angle computations.

A more intuitive algorithm would be:

  1. Compute the polygon's extreme points in the y direction. Call them ymin and ymax.
  2. Construct two horizontal lines of support through ymin and ymax. Since this is already an anti-podal pair, compute the distance, and keep as maximum.
  3. Rotate the lines until one is flush with an edge of the polygon.
  4. A new anti-podal pair is determined. Compute the new distance, compare to old maximum, and update if necessary.
  5. Repeat steps 3 and 4 until the anti-podal pair considered is (ymin,ymax) again.
  6. Output the pair(s) determining the maximum as the diameter pair(s).

Still, the above procedure (given in pseudocode) happens to be very useful, as other information can be obtained from the anti-podal pairs, like the width of a convex polygon.

 

 

The width of a convex polygon

The width of a convex polygon is defined as the minimum distance between parallel lines of support. This definition already hints at the characteristics of the width. However, a convex polygon admits parallel lines of support in any direction, and for each direction the width is (usually) different. Fortunately, not every direction needs to be checked.

Consider a line segment [a,b], and two parallel lines through a and b. By rotating the lines about these points, the distance between them either increases or decreases. Specifically, there is always a preferred direction of rotation that the lines can be rotated to decrease the distance between them.

This simple result can be applied to the problem of the width: not all directions need to be considered. Suppose a polygon is given, along with two parallel lines of support. If neither of the lines coincides with an edge, then it is always possible to rotate them to decrease the distance between them. Therefore, two parallel lines of support do not determine the width unless one of them coincides with an edge.

This means that only
anti-podal vertex-edge and edge-edge pairs need to be considered in the computation of the width.

A convex polygon's width. The diameter pair, shown as black dots admits parallel lines of support (shown in red). The diameter is highlighted in light blue.


An algorithm similar to that of the diameter problem can be used to go through the anti-podal pairs list of the polygon, determine the vertex-edge and edge-edge pairs, and compute the width from that. An alternative would be:

  1. Compute the polygon's extreme points in the y direction. Call them ymin and ymax.
  2. Construct two horizontal lines of support through ymin and ymax. If one (or both) of the lines coincide with an edge, then a anti-podal vertex-edge or edge-edge pair is already determined. In that case, compute the distance between the lines, and keep as the minimum.
  3. Rotate the lines until one is flush with an edge of the polygon.
  4. A new anti-podal vertex-edge pair (or edge-edge pair in case both lines coincide with edges) is determined. Compute the new distance between the lines, compare to old minimum, and update if necessary.
  5. Repeat steps 3 and 4 until the lines of support (calipers) have reached their original horizontal position.
  6. Output the pair(s) determining the minimum as the width determining pair(s).

Again, the more intuitive algorithm has the disadvantage of require angle computations. However, sometimes the simpler, more intuitive Rotating Calipers algorithm must be used, as in the computation of the maximum distance between convex polygons.

 

 

The maximum distance between two convex polygons

Given two convex polygons P and Q, the goal is to find the pair(s) of points (p,q) (p belonging to P and q to Q) maximizing the distance between them.

Intuitively, these points will not belong to the interior of their respective polygons. The situation is in fact similar to the diameter problem:

The maximum distance between two convex polygons P and Q is determined by anti-podal pair between the polygons.
Although the terminology is the same, this definition is different from that of
anti-podal pair for a given convex polygon.
The essential difference with an
anti-podal pair between convex polygons is that the lines of support are directed and have opposite direction. An example is illustrated below:

Not only does the above result imply that only pairs of vertices should be checked, only specific pairs need to be considered. The fact that they admit parallel lines of support calls for an algorithm based on the Rotating Calipers paradigm.
Consider the following algorithm, where the input is assumed to be two convex polygons P and Q with m and n vertices respectively given in clockwise order.

  1. Compute the vertex with minimum y coordinate for P (call it yminP) and the vertex with maximum y coordinate for Q (call it ymaxQ).
  2. Construct two lines of support LP and LQ for the polygons at yminP and ymaxQ such that the polygons lie to the right of their respective lines of support. Then LP and LQ have opposite direction, and yminP and ymaxQ form an anti-podal pair between the polygons.
  3. Compute dist(yminP,ymaxQ) and keep it as the maximum.
  4. Rotate the lines clockwise until one of them coincides with an edge of its polygon.
  5. A new anti-podal pair is determined. The new distance is computed, compared to the current maximum, which is updated if necessary. If both lines of support coincide with edges, then a total of three anti-podal pairs (combinations of the previous vertices and the new vertices) need to be considered.
  6. Repeat steps 4 and 5, until the new pair considered is (yminP,ymaxQ).
  7. Output the maximum distance.

The Rotating Calipers paradigm ensures all possible anti-podal pairs are considered. Furthermore, the whole algorithm has linear time complexity, since (besides the initialization), there are only as many steps as there are vertices.

A similar algorithm can be used for the
minimum distance between two convex polygons.

 

 

The minimum distance between two convex polygons

Given two disjoint (i.e. non-intersecting) convex polygons P and Q, the goal is to find the pair(s) of points (p,q) (p belonging to P and q to Q) minimizing the distance between them.

The fact that the polygons are disjoint is important, since it is assumed the polygon contains its interior. If the polygons intersect, then the minimum distance is meaningless. However, another version of this problem, the minimum vertex distance between convex polygons has solutions in intersecting and non-intersecting cases.

Back to the main problem: intuitively, the points determining the minimum distance will not belong to the interior of their respective polygons. Similar to the maximum distance problem, we have the following result:

The minimum distance between two convex polygons P and Q is determined by
anti-podal pair between the polygons. As there are three cases for anti-podal pairs between convex polygons, three cases for the minimum distance can occur:

  1. The vertex-vertex case
  2. The vertex-edge case
  3. The edge-edge case


In other words, the points determining the minimum distance are not necessarily vertices. The following three examples illustrate the above result:

Given this result, an algorithm based on the Rotating Calipers naturally comes to mind:
Consider the following algorithm, where the input is assumed to be two convex polygons P and Q with m and n vertices respectively given in clockwise order.

  1. Compute the vertex with minimum y coordinate for P (call it yminP) and the vertex with maximum y coordinate for Q (call it ymaxQ).
  2. Construct two lines of support LP and LQ for the polygons at yminP and ymaxQ such that the polygons lie to the right of their respective lines of support. Then LP and LQ have opposite direction, and yminP and ymaxQ form an anti-podal pair between the polygons.
  3. Compute dist(yminP,ymaxQ) and keep it as the minimum.
  4. Rotate the lines clockwise until one of them coincides with an edge of its polygon.
  5. If only one line coincides with an edge, then the vertex-edge anti-podal pair distance should be computed along with the new vertex-vertex anti-podal pairA distance. Both distances are compared the current minimum, which is updated if necessary. If both lines of support coincide with edges, then the situation is somewhat more complex. If the edges "overlap", that is if one can construct a line perpendicular to both edges and intersecting both edges (but not at vertices), then the edge-edge distance should be computed. Otherwise the three new vertex-vertex anti-podal pair distances are computed. All distances are compared to the current minimum which is updated if necessary.
  6. Repeat steps 4 and 5, until the lines reach (yminP, ymaxQ) again.
  7. Output the minimum distance.

The Rotating Calipers paradigm ensures all possible anti-podal pairs (and all possible subcases) are considered. Furthermore, the whole algorithm has linear time complexity, since (besides the initialization), there are only as many steps as there are vertices.

The maximum and minimum distance problems show that the Rotating Calipers paradigm can be used in different ways (compared to the previous problems of diameter and width). The paradigm can be applied to a two polygon case.
The smallest-box problem (
minimum area enclosing rectangle) shows yet another way of using the Rotating Calipers, by using two sets of orthogonal lines of support on the same polygon.

 

 

 

The minimum area enclosing rectangle for a convex polygon

Given a convex polygons P, what is the smallest-box (in terms of surface are) enclosing P? Technically, given a direction, the extreme points for P can be computed and an enclosing rectangle is therefore constructed. But is it necessary to check each single orientation in order to obtain the rectangle with minimum area? The answer, thankfully, is no.

The minimum area rectangle enclosing a convex polygon P has a side collinear with an edge of the polygon.

The above result dramatically restricts the range of possible rectangles. Not only is it not necessary to check all directions, but only as many as the polygon's number of edges.

Illustrating the above result: the four lines of support (red), with one coinciding with an edge, determine the enclosing rectangle (blue).


A simple algorithm would be to compute for each edge the corresponding rectangle collinear with it. But the construction of this rectangle would imply computing the polygon's extreme points for each edge, a process that takes O(n) time (for n edges). The entire algorithm would then have quadratic time complexity.

A much more efficient algorithm can be found. Instead of recomputing the extreme points, it is possible to update them in constant time, using the Rotating Calipers.
Indeed, consider a convex polygon, with a two pair of lines of support through all four usual extreme points in the x and y directions. The four lines already determine an enclosing rectangle for the polygon. But unless the polygon has a horizontal or vertical edge, this rectangle is not a candidate for the minimum area.
However, the lines can be rotated until the above condition is satisfied. This procedure is at the heart of the following algorithm. The input is assumed to be a convex polygon with n vertices given in clockwise order.

  1. Compute all four extreme points for the polygon, and call them xminP, xmaxP, yminP ymaxP.
  2. Construct four lines of support for P through all four points. These determine two sets of "calipers".
  3. If one (or more) lines coincide with an edge, then compute the area of the rectangle determined by the four lines, and keep as minimum. Otherwise, consider the current minimum area to be infinite.
  4. Rotate the lines clockwise until one of them coincides with an edge of its polygon.
  5. Compute the area of the new rectangle, and compare it to the current minimum area. Update the minimum if necessary, keeping track of the rectangle determining the minimum.
  6. Repeat steps 4 and 5, until the lines have been rotated an angle greater than 90 degrees.
  7. Output the minimum area enclosing rectangle.

Because two pairs of "calipers" determine an enclosing rectangle, this algorithm considers all possible rectangles that could have the minimum area. Furthermore, aside from the initialization, there are only as many steps in the algorithm's main loop as there are vertices. Thus the algorithm has linear time complexity.

A similar but less known problem is the
minimum perimeter enclosing rectangle. It is interesting to note that these two problems are distinct since there exists (although rare) cases of polygons where the minimum area enclosing rectangle does not coincide with the minimum perimeter enclosing rectangle.

 

 

The minimum perimeter enclosing rectangle for a convex polygon

This problem parallels that of the minimum area enclosing rectangle closely. The goal is to find the smallest-box (in terms of perimeters) enclosing a polygon P.

It is interesting to note that very often the two rectangles minimizing the perimeter and the area happen to coincide. One can ask if this is always the case. The following example gives the answer: a polygon is shown (in grey) with its minimum-area enclosing rectangle (to the left) and the minimum perimeter enclosing rectangle (right).


Now, given a direction, the extreme points for P can be computed, in order to determine an enclosing rectangle. But, as in the area problem, it is not necessary to check each single orientation in order to obtain the rectangle with minimum perimeter, thanks to the following result:

The minimum perimeter rectangle enclosing a convex polygon P has a side collinear with an edge of the polygon.

This result restricts the range of possible rectangles to consider to those coinciding with one of the polygon's edges.

Illustrating the above result: the four lines of support (red), with one coinciding with an edge, determine the enclosing rectangle (blue).


Because of the similarities with its area counterpart, this problem can be solved with a similar algorithm based on the Rotating Calipers.
The input for the following algorithm is assumed to be a convex polygon with n vertices given in clockwise order.

  1. Compute all four extreme points for the polygon, and call them xminP, xmaxP, yminP ymaxP.
  2. Construct four lines of support for P through all four points. These determine two sets of "calipers".
  3. If one (or more) lines coincide with an edge, then compute the perimeter of the rectangle determined by the four lines, and keep as minimum. Otherwise, consider the current minimum perimeter to be infinite.
  4. Rotate the lines clockwise until one of them coincides with an edge of its polygon.
  5. Compute the perimeter of the new rectangle, and compare it to the current minimum perimeter. Update the minimum if necessary, keeping track of the rectangle determining the minimum.
  6. Repeat steps 4 and 5, until the lines have been rotated an angle greater than 90 degrees.
  7. Output the minimum perimeter enclosing rectangle.

Because two pairs of "calipers" determine an enclosing rectangle, this algorithm considers all possible rectangles that could have the minimum perimeter. Furthermore, aside from the initialization, there are only as many steps in the algorithm's main loop as there are vertices. Thus the algorithm has linear time complexity.

The set of problems deal with triangulations. Two specific ones, the
onion triangulation and the spiral triangulation are studied.

 

 

 

Onion triangulations

Given a set of points on the plane, the goal is to obtain a triangulation of that set of points.

Much research has been done to improve the efficiency of triangulation algorithms, from Lennes's original algorithm (1911) having quadratic time complexity to Chazelle's algorithm (1991) has linear time complexity.

The focus here is on a specific type of triangulation, based on the onion-peeling of a set of points.
Consider a set S of n on the plane. Compute the convex hull of S, and let S' be the set of points remaining in the interior of the hull. Compute then the convex hull of S' and recursively repeat this process until no more points remain. One ends up with a sequence of nested convex hulls, called the onion-peeling of S. This structure can be obtained in O(n log n) time, thanks to an algorithm by Chazelle.

The onion-peeling of a set of points. Note that the innermost structure can either be a line segment or a single point, besides a convex polygon. This graph gives information as to the layering of the points, i.e. how "deep" points are relative to each other other.


The region between two nested convex hulls is called an annulus. Toussaint (1986) presents a simple algorithm for triangulating an annulus, using the Rotating Calipers. Using his method, once the onion peeling has been obtained, the entire set can be triangulated in linear time. Furthermore, the triangulation has two advantages: it keeps the onion-peeling as a subgraph, and it is hamiltonian, that is the dual of the triangulation graph is a chain.

The algorithm for triangulating an annulus is quite simple. The input is assumed to be a convex hull Q nested in an other hull P, both given in clockwise order.

  1. Insert the edges of the hulls as edges in the triangulation.
  2. Compute the points with minimum x coordinate for both P and Q, calling them xmin(P) and xmin(Q).
  3. Construct two vertical lines of support (the calipers) at xmin(P) and xmin(Q); call them LP and LQ.
  4. Insert (xmin(P), xmin(Q)) as an edge in the triangulation.
  5. The "current" points p and q for LP and LQ are xmin(P) and xmin(Q), respectively.
  6. Rotate the lines clockwise until one coincides with an edge. A new vertex has therefore been "hit" by one of the lines.
    • If it belongs to P (call it p'), insert (p', q) into the triangulation. Update the "current" points to p' and q.
    • If it belongs to Q (call it q'), insert (p, q') into the triangulation. Update the "current" points to p and q'.
    • In case of parallel edges, both lines of support coincide with edges, and two new vertices are "hit" (call them p' and q'). Then, insert (p', q'), and either (p, q') or (p', q) into the triangulation. Update the "current" points to p' and q'.
  7. Repeat the previous step until the starting minimum points are reached.

An example of a triangulated annulus is shown below:


The above algorithm has linear time complexity. When used to triangulate a set of points, a single convex hull is run (at most) twice through the procedure, once as the inner hull of the annulus, and once as the outer. Then the entire running time for triangulating a set of n points remains O(n).

Another specific and closely related triangulation is the
spiral triangulation based on the convex spiral of a set of points.

 

 

 

Spiral triangulations

The spiral triangulation of a set of points is a triangulation graph based on the convex spiral of that set.
The convex spiral is obtained in the following way:

  1. Start at a given extreme point (i.e. the minimum point in a given direction), say the point with minimum x coordinate
  2. Construct a vertical line through that point.
  3. Rotate the line in a fixed direction (always clockwise or always counterclockwise), until the line "hits" another vertex.
  4. Join the two points by a line segment.
  5. Repeat steps 3 and 4, but always ignoring points already hit.

In essence, the procedure somewhat resembles the gift-wrapping algorithm for computing convex hulls, but with the difference that the loop is never closed. For a set of points whose hull has h points, 2h convex spirals exist: for each starting point there exists a clockwise and a counterclockwise spiral.

A set of points (left), and its clockwise convex spiral, with minimum x coordinate point as the starting point.


Interestingly, the convex spiral and the onion-peeling of a set can be obtained one from the other in linear time. Furthermore, similar to the onion triangulation, one defines the spiral triangulation of a set of points, whose subgraph is the convex spiral.

The algorithm for obtaining the spiral triangulation, although based on the annulus triangulation algorithm, is somewhat more complicated, as the spiral must be split into proper convex chains. The input is assumed to be a clockwise convex spiral C of a set, with C={p1, ..., pn}.

  1. Insert the edges of the convex spiral as edges in the triangulation.
  2. Starting with p1, find the point ph being the last point on the convex hull of the set of points.
  3. Extend the last edge of the convex spiral [p(n-1),pn] until it intersects the convex spiral. Label that point q'.
  4. Construct the line locally tangent to C at q'. Rotate the line counterclockwise until it hits the first point of C such that the line is parallel to [p(n-1),pn]. Label this point q.
  5. Insert [p(n-1),q] into the triangulation.
  6. This construction splits the convex spiral into two regions: the outer spiral region and the inner polygonal region. Let Co={p1, ... ,q} and let Ci={ph, ... ,q, ... , pn}. The construction is illustrated below:

    Top left: the construction. Top right: the outer spiral and the inner polygonal regions. Bottom: The outer and inner convex chains Co and Ci.


  7. The outer spiral region is triangulated as an annulus. Co and Ci can be locally viewed as nested convex hulls.
  8. The inner polygonal region is starshaped at pn and therefore easily triangulated.
  9. The union of these two triangulations form the complete spiral triangulation.

An example of a convex spiral and its triangulation is shown below:


The above algorithm has linear time complexity, based on the running time of the annulus triangulation algorithm.

 

Quadrangulations

Although triangulations are a much more commonly used structure, recently quadrangulations have been shown to be prefferable in some particular cases, such as scattered data interpolation and finite element methods.

A quadrangulation is essentially a subdivision of a set of points into quadrilaterals. Some essential differences (aside the obvious ones) with triangulations should be noted:
First, not all sets of points admit quadrangulations. In fact, only even-numbered sets do. For odd-numbered sets, additional points (called Steiner points) are sometimes added to the original set, in order to be able to obtain a quadrangulation.
In addition, it is often desired that the quadrilaterals obtained have some "nice" properties, like convexity. This issue is irrelevant in triangulations.

Many simple quadrangulation algorithms exist. For instance, consider triangulating a set of points first, and then adding a Steiner point in the interior of each triangle, and at the midpoint of each edge. Connecting these new points yields a quadrangulation (this idea is due to DeBerg).

Bose and Toussaint (1997) propose starting with the
spiral triangulation of a set of points and removing diagonals, in order to obtain a quadrangulation.
If the set of points is even-numbered, then every second diagonal (added during the spiral triangulation algorithm) is removed, yielding a quadrangulation. If there is an odd number of points, then starting from the last diagonal added, every other diagonal (i.e. the last, the third to last, etc.) is removed, a Steiner point is added near the first diagonal, which is removed. The following ilustrates the first case (even-numbered set of points). The spiral triangulation (left), and the resulting quadrangulation (right).

Since the diagonal removal procedure (and necessary updates) takes O(n) time, this quadrangulation algorithm has the same time complexity as the
spiral triangulation one. Among the advantages of this algorithm are its simplcity in concept and implementation (once the convex spiral has been obtained), and the fact that it yields a "nicer" quadrangulation than many rival algorithms.

The next set of problems focuses on convex polygons, and specifically, operations on convex hulls, such as
merging two convex hulls.

 

 

 

Merging convex hulls

Consider the following problem: given two convex polygons, what is the smallest convex polygon containing their union? The answer is the polygon corresponding to the merged convex hulls.

Merging convex hulls can be done in the trivial way: given all the vertices of both polygons, compute corresponding hull. More efficient algorithms exist, and involve finding the bridges between the polygons. The following figure illustrates this concept:

Two disjoint convex polygons. The merged hull consists of convex chains belonging to the polygons (shown is solid blue lines), joined by bridges between the polygons (shown in dashed blue lines)


Given two disjoint polygons, there exist two bridges between the polygons. When the polygons intersect, there may be as many as there are vertices, as illustrated below:

Two intersecting convex polygons. The merged hull consists only of bridges between the polygons (shown in dashed lines). There are eight bridges joining eight vertices.


The merge operation is at the heart of the divide-and-conquer approach. This applies to polygons as well. A very simple way to obtain the convex hull of a set of points is to divide the point set in two, and recursively compute the convex hulls of the two new smaller sets, and then merge them. Each set is again split, until the number of elements is small enough (say three or less) so that the convex hull may be trivially obtained.
Toussaint proposes using the Rotating Calipers to find the bridges between two convex polygons. The main advantage of his method is that it involves no backtracking, and the polygons can intersect. (Other algorithms require the polygons to be disjoint). The following result is the basis for his algorithm:
Given convex polygons P={p(1), ... , p(m)} and Q={q(1), ... , q(n)}, a pair of points (p(i), q(j)) form a bridge between P and Q if, and only if:

  1. (p(i), q(j)) form a co-podal pair.
  2. p(i-1), p(i+1), q(j-1), q(j+1), all lie to the same side of the line joining (p(i), q(j)).

Assuming the polygons are given in standard form and the vertices is clockwise order, the algorithm is as follows:

  1. Compute the vertices with maximum ycoordinate for both P and Q. If more than one exist, take the ones with greater x coordinates.
  2. Construct horizontal lines of support at these points, directed such that the polygons lie to their right (thus they point to the positive end of the x axis).
  3. Rotate both lines of support clockwise until one coincides with an edge. A new co-podal pair (p(i), q(j)) is determined. In the case of parallel edges, three co-podal pairs are determined.
  4. For all valid co-podal pairs (p(i), q(j)): check if p(i-1), p(i+1), q(j-1), q(j+1), all lie to the same side of the line joining (p(i), q(j)). If so, then the co-podal pair is a bridge, and is labelled as such.
  5. Repeat steps 3 and 4 until the lines of support reach their original position.
  6. All possible bridge pairs have thus been determined. Construct the merged convex hull by joining the proper convex chains between consecutive bridges.

The above result ensures the correctness of the algorithm. The running time is dominated by steps 1, 5 and 6, each running in O(N) time (where N is the total number of vertices). The algorithm therefore has linear time complexity.

A bridge between convex polygons determines in fact
common tangents between the polygons, another useful concept. In addition, bridges are also at the heart of an algorithm computing the intersection between two convex polygons.

 

 

 

Finding common tangents

Common tangents are simply lines that are tangent to both polygons at the same time, and so that the both polygons lie to one side of that line. In other words, a common tangent is a line of support for both polygons. An example is illustrated below:

Two disjoint convex polygons and a common tangent line between them.


In fact, common tangents are determined by the same pairs of points between the polygons that determine the bridges. Hence, given two disjoint polygons, there exist two common tangents between the polygons, and when the polygons intersect, there may be as many as there are vertices.
The same algorithm computing the bridges between two convex polygons (i.e. the
merge algorithm) can therefore be used to determine common tangents.

Another "version" of lines tangent to both polygons are
critical support lines. In that case the polygons lie on opposite sides of the line.

Bridges can also be used in computing the
intersection of two convex polygons.

 

 

 

Intersecting convex polygons

Given two convex polygons, the first question one should ask before proceeding is: "Do they intersect?". A logarithmic time algorithm is provided by Chazelle and Dobkin (1980) in a paper appropriately named "Detection is easier than computation". Given that the polygons intersect, many algorithms computing the intersection xist. The interesting point here is a result (by Guibas) demontrating a one-to-one correspondence between the intersection points of the polygons and the bridges between them.

Two convex polygons (light red and blue) and their intersection (light purple). The intersection points are shown in red. Each point corresponds to a bridge (shown as dotted red lines) between the polygons.


Toussaint (1985) uses Guibas' result, and his previous algorithm for finding the bridges to compute the intersection points. His algorithm uses the bridges to compute the intersection points. Once these are found, similar to merging convex hulls, convex chains joining the intersection points form the intersection of the polygons.

The details of the algorithm, especially the computation of the intersection points from the bridges can be found in Toussaint's paper:

G.T. Toussaint.
A simple linear algorithm for intersecting convex polygons. The Visual Computer. 1: 118-123. 1985.

The next problem involves finding the
critical support lines between two convex polygons.

 

 

Critical support lines

Critical support lines (commonly referred to as CS lines) between two convex polygons are lines tangent to both polygons but such that they lie on opposite sides of the line. In other words, they separate the polygons.
CS lines have applications in motion planning, visibility, range fitting.

Illustrated below are two convex polygons and the two critical support lines between them.

Note that assuming the data is given in standard form, CS lines will only intersect the two polygons at two vertices only. Hence, a CS line is determined by a pair of vertices between the polygons.
The following result characterizes this pair:

Given two convex polygons P, Q, two vertices p(i), q(j) (belonging to P and Q respectively) determine a CS line if, and only if:

  1. p(i), q(j) form an anti-podal pair between the polygons.
  2. p(i-1),p(i+1) lie on one side of the line (p(i), q(j)) while q(j-1),q(j+1) lie on the other.

Using this result, the CS lines can easily be determined. Only anti-podal pairs between the polygons need to be checked. Thus, Toussaint proposes to use the Rotating Calipers. Assuming the polygons are given in standard form and clockwise order, consider the following:

  1. Compute the vertex with minimum y coordinate for P (call it yminP) and the vertex with maximum y coordinate for Q (call it ymaxQ).
  2. Construct two lines of support LP and LQ for the polygons at yminP and ymaxQ such that the polygons lie to the right of their respective lines of support. Then LP and LQ have opposite direction, and yminP and ymaxQ form an anti-podal pair between the polygons.
  3. Let p(i)= yminP, and let q(j)= ymaxQ. (p(i), q(j)) form an anti-podal pair between the polygons. Check if p(i-1),p(i+1) lie on one side of the line (p(i), q(j)) and if q(j-1),q(j+1) lie on the other. If so, then (p(i), q(j)) determine a CS line.
  4. Rotate the lines clockwise until one of them coincides with an edge of its polygon.
  5. A new anti-podal pair is determined. If both lines of support coincide with edges, then a total of three anti-podal pairs (combinations of the previous vertices and the new vertices) need to be considered. For all new anti-podal pairs, perform the above checks.
  6. Repeat steps 4 and 5, until the new pair considered is (yminP,ymaxQ).
  7. Output the CS lines.


This algorithm basically rotates the lines of support around the polygons, sequentially finding all anti-podal pairs between them. Every time a pair is determined, all necessary checks are performed. By the above result characterizing CS lines, then all critical support lines are found.
The algorithm's running time is dominated by steps 1 and 6, which take O(n) time each (all checks are done with unit-time cost. Since there are O(n) anti-podal pairs, the total cost is O(n)).

The final operation on convex polygons studied is the
vector sums of convex polygons.

 

 

 

Vector sums of convex polygons

Given two convex polygons P and Q on the plane, the vector sum of P and Q, denoted P + Q is defined as follows:

P+Q={p+q} for all p and q belonging to P and Q respectively.


The vector sums of polygons, also referred to as the Minkowski sum is used in motion planning.

Considering the definition above, many questions can be asked about the nature of the set P+Q, the properties it holds, etc. The following result help characterize vector sums of polygons:

  1. P+Q is a convex polygon.
  2. The vertices of P+Q are sums of vertices of P and Q
  3. The vertices of P+Q are sums of co-podal pairs between P and Q.
  4. Given that P and Q have m and n vertices each, P+Q has no more than m+n vertices.

Finally, the following result not only characterizes the problem, but provides a way of incrementally computing the vector sum of two convex polygons, vertex by vertex:
Given the k-th vertex z(k) of P+Q, with z(k) = p(i) + q(j). Construct two parallel lines of support at p(i) and q(j) such that the polygons lie to the right of their respective lines. The lines determine angles theta(i) and phi(j) at p(i) and q(j) respectively (see the illustration below)

Then the next vertex z(k+1) equals:

  • p(i+1) + q(j) if theta(i) < phi(j)
  • p(i) + q(j+1) if theta(i) > phi(j)
  • p(i+1) + q(j+1) if theta(i) = phi(j)



Consider as an example, the following polygons, and their vector sum (below).

Two convex polygons. The first polygon's edges are in red, the second's in blue.



The vector sum of the above polygons. Its edges' colours correspond to the originating polygon's.


Using the last result, it is very easy to formulate an algorithm computing the vector sun. The first vertex can be the sum of the extreme vertices in a given direction (say the negative y direction). Lines of support are constructed, and upon computation of the angles, the next point is clear. All that is needed is to rotate the lines simultaneously to the new position, to determine the new angles.

The algorithm's correctness follows from the main result; it has linear time complexity, from the fact that at each step one vertex for the vector sum is output, and since there are at most m+n of these, the total running time is m+n.

 

 

 

 

Thinnest strip transversals

Consider the following facility location problem: A set of "customers" is given as a family F of convex polygons on the plane. The goal is to find the "facility", a line on the plane, minimizing the maximum distance from the line to any customer.

This last point needs some clarification. The distance from the line to any polygon is the minimum orthogonal distance from the line to any point on that polygon. Therefore, each polygon has a unique distance to the line.
Now, given the family of polygons and a line on the plane, each polygon has a distance to the line. Therefore, a maximum line-polygon distance exists for the entire family. This distance depends on the line as well as the family of polygons.
The goal of the problem is: given a specific family of polygons, find the line that minimizes this maximum. Other versions of the problem exist, notably that of finding the line minimizing the sum of distances, and the sum of weighted distances to the polygons.

The results presented here are due to Robert and Toussaint (1990).
The main problem is equivalent to finding the minimum width strip (a region on the plane bounded by two parallel lines) intersecting all polygons of the family. Then, the medial axis of that strip (the line parallel and equidistant to the strip's boundaries) is the desired line minimizing the maximum distance.

The following definitions are necessary for the discussion of the main result:

A line l on the plane, defined by the equation ax+by+c=0 (with b > 0 or a=-1) divides the plane into two regions: the upper half Hu(l) of points p=(px,py) such that apx + apy + c >= 0 and the lower half Hl(l) of points p=(px,py) such that apx + apy + c <= 0.
By this definition, if the line is vertical, the upper half contains negative infinity of the x axis.

Furthermore, a strip can be defined as the intersection of the upper-half of one line, with the lower-half of another (parallel) line.

Given a convex polygon P, and an orientation theta, the lower tangent line tl(P, theta) is a line having angle theta with respect to the positive x axis, intersecting P and such that P belongs to the upper-half of tl(P, theta). The intersection point (or points) is called the lower point.
Similarly, the upper tangent and upper point are defined.
Given a family of polygons and a fixed orientation, a set of lower points and upper points is determined.

Finally, consider the following result:
Given a family F of polygons, and an orientation theta , a strip S (given by the intersection of Hu(l1) with Hl(l2) of width greater than 0 is the minimum width strip for F (at that orientation) if, and only if there exist two polygons P and Q belonging to F such that

  • The intersection of P and Hu(l1) is in l1.
  • The intersection of Q and Hl(l2) is in l2.


The main result follows from this: the minimum width strip (with a given orientation theta) for a family F of convex polygons is determined by lines l1 and l2 such that
l1=tl(CH(UP(F, theta)), theta) and
l2=tu(CH(LP(F, theta)), theta)

A family of convex polygons, and the minimum width strip for a given orientaiton. The convex hulls of lower and upper half points are shown, illustrating the above result. Note the existence of the two polygons intersecting the strip only at one vertex.


Therefore, if one can determine the sequence of lower and upper points for the family's polygons, computing the convex hulls for a given direction determine the minimum width-strip. As Robert and Toussaint explain, luckily these convex hulls need not be completely recomputed each time: they need only be updated. Indeed, consider two close orientations: it is likely for many (or all) polygons to have the same upper and lower points for these two orientations. This fact also implies that only a critical number of orientations (when a lower or upper point changes) need to be checked.

As the focus here is on the Rotating Calipers paradigm, it is not the purpose to go into the details of the algorithm. The authors propose the use of the Rotating Calipers to compute upper and lower points for the polygons. The following is the outline of an algorithm accomplishing just that. Given a convex polygon P:

  1. Find the vertices with minimum and maximum y-coordinates. Label these as p and q and construct horizontal lines of support through them.
  2. Rotate the lines counterclockwise by an angle theta until one is flush with one of the polygon's edges.
  3. If the vertex hit was the vertex after p (given a counterclockwise order), then p is the lower point for orientations 0 (inclusive) to theta (non-inclusive). If it is the vertex after q, then q is the upper point for the same angle interval. Possibly both these cases occur if edges are parallel.
  4. Update the current points to the new vertex of vertices hit, and the current angle.
  5. Repeat steps 2 to 4, updating the angle intervals accordingly, until the new current angle is at least 180 degrees (at which point the lines return to their original positions, but in reverse order).

The directions at which a line is flush with one of the polygon's edges are called critical directions. It is only. at these orientations that lower or upper points can change. At a critical direction, since the line intersects two vertices, the lower or upper point is defined as the one intersecting the line if it is rotated counterclockwise.

Once the critical directions (given in order) are known, a strip can be computed for the first direction. Then, for the second critical direction, at least one lower or upper point is updated. Because of this, the convex hulls need only be updated, and not recomputed. Once this is done, the new strip is obtained, and its width (the orthogonal distance between its boundaries) computed. This process is repeated for all critical directions. Note that if at any point in the process a strip f width 0 is found, then the process can be stopped because a line is found that intersects all polygons of the family.

For the complete algorithm, discussion of the correctness and the running time, consult the authors' paper:

J.-M. Robert, G.T. Toussaint.
Computational geometry and facility location. Proc. Internatioanl Conf. on Operations Research and Management Science, Manila, The Philippines, Dec. 11-15, 1990. pp B-1 to B-19.

 

 

 

另外自己胡乱翻译了两节

谁能告诉我这个洋葱三角形是个什么东西……Onion triangulations

 

M.I. Shamos在1978年发表的Ph.D论文“Computational Geometry"标志着计算机科学中计算几何学的诞生。在他的众多成果中,他给出了一个计算凸包直径的非常简单的算法,也就是计算突包中一对点之间的最短距离。

     研究发现,凸包的直径是由凸包中的对踵点决定的。Shamos给出了一种时间复杂度为Ω(n)的寻找对踵点的算法。由于一个凸包中最多只有3n/2对对踵点,所以我们可以在Ω(n)的时间内计算出直径。

     正如Toussaint后来说到,Shamos的算法就像是用一对测径器卡着这个多边形旋转一样。因此我们称此为“旋转卡壳”。1983年Toussaint发表了一篇论文,在这篇论文中,他用类似的方法解决了许多的问题。从那时开始许多以此为基础的新的算法诞生了,解决了一系列的问题。

 

他们包括:

     计算距离

             

            ¨  凸多边形的直径              

              ¨  凸多边形的宽度

              ¨  两个凸多边形之间的最小距离

                  ¨   两个凸多边形之间的最大距离

 

          外接三角形

 

             ¨ 外接三角形的最小面积

             ¨ 外接三角形的最小周长

 

  

 

The diameter of a convex polygon

 

practice : http://acm.pku.edu.cn/JudgeOnline/problem?id=2187

 

     一个多边形的直径定义为这个多边形中任意两点之间的最大距离,而这样的点对可能存在多个。实际上,如果一个多边形有n个顶点,那么他最多有n对这样的点。

     很明显一个凸多边形的直径不可能由他内部的点决定。我们应该在他的边界上寻找。事实上,我们只要检查对踵点。1978年Shamos提出了一种时间复杂度为Ω(n)的算法计算一个有n个顶点的多边形的直径。我们可以通过扫描这些对踵点,取其中距离最远的,便可得到多边形的直径。下面是Shamos算法的为代码,由Preparata和Shamos发表于1985年。

 

输入是一个多边形 P = (p1,p2,...,pn)

 

 

 

 

 

 1 begin
 2      p0:= pn;
 3      q:=
NEXT[p];
 4      while (Area(p,NEXT[p],NEXT[q]) > Area(p,NEXT[p],q)) do

 5           q:= NEXT[q];
 6           q0:=
q;
 7           while (q != p0) do

 8                begin
 9                     p:= NEXT[p];
10 
                    Print(p,q);
11                     while (Area(p,NEXT[p],NEXT[q]) > Area(p,NEXT[p],q) do

12                          begin
13                               q:= NEXT[q];
14                               if ((p,q) != (q0,p0)) then
 Print(p,q)
15                               else
 return
16                          end
;
17                     if (Area(p,NEXT[p],NEXT[q]) = Area(p,NEXT[p],q)) then

18                       if ((p,q) != (q0,p0)) then  Print(p,NEXT[q])
19                       else
 Print(NEXT[p],q)
20                end

21 end .
22 

 

 

 

    

NOTE: Print(p, q) 表示输出一对对踵点 (p, q), Area(p, q, r)表示由p, q, r三点构成的三角形的带符号的面积。

     尽管这个为代码并不像通常的旋转卡壳的算法那么直观,但他们确实是一样的,并且避免了所有角度的计算。

 

一个更加直观的方法是这样的:

     1.计算多边形在y轴上的极值,记为ymin, ymax。

     2.建立两条穿过ymin和ymax的水平线,由于他在一对对踵点上,我们需要计算他们之间的距离,并记为maximum。

     3.旋转这两条直线,知道其中一条遇到多边形的一个边。

     4.找到一对新的最终点。计算两点之间的距离,并同maximum比较,更新maximum。

     5.重复第3部和第4部直到重新找到(ymin, ymax)这对对踵点为止。

     6.输出决定多边形直径的一对点pair(s)。

 

不过上面的由为代码表述的过程非常有用,因为我们可以通过对踵点得到许多有用的信息,比如凸多边形的宽度。

 

 

The width of a convex polygon

 

     一个凸多边形的宽度定义为由多边形的边或点决定的两条平行线之间的最短距离。这样的定义已经由他的名称暗示了。

     但是一个图多边形可以有多组互相平行的直线,而且每组间的距离都不相同。幸运的是,并不是每对平行线都需要检查的。

 

     考虑一个线段[a, b],和穿过a, b的两条平行线。通过旋转这两条线,他们之间的距离要么增大要么减小。但是一定有一个方向能够减小他们之间的距离。

 

     这个简单的结论可以用于解决计算宽度的问题:并不是每个角度都需要检查的。假设有个个多边形,和两条平行线。如果没有一条线是和多边形的一个边是重合的,那么我们一定能通过旋转减小这两条线之间的距离了。因此,当两条线中至少有一条同多边形的某条边重合时,他们之间的距离才有可能成为这个多边形的宽度。

 

     这表明只有 anti-podal vertex-edge 和edge-edge需要检查。

 

     同计算直径的算法类似,我们可以通过扫描对踵点找出 vertex-edge 和 edge-edge pairs,通过他们计算出多边形的宽度。算法如下:

 

     1.计算出多边形y轴上的最大值和最小值,记为ymin, ymax。

     2.建立两条穿过ymin和ymax的水平线。如果这是已经有一条(或者两条)线同多边形的边重合的换,计算他们之间的距离并记为minimum。

     3.旋转两条直线,直到其中一条遇到多边形的一个边。

     4.找到一对新的vertex-edge or edge-edge,计算他们之间的距离,并更新minimum。

     5.重复步骤3和4,知道两条直线回到他们的起始位置为止。

     6.输出决定多边形宽度的pair(s)

 

     我们又看到,这种更加直观的算法有他的不足之处,他需要计算角度。但是有时候我们必须要使用这种直观的旋转卡壳的算法,比如在计算两个凸多边形之间的最远距离的时候。

 

你可能感兴趣的:(IP)