Rotation Jam (calculates the two points farthest from the convex polygon)

Source: Internet
Author: User
Tags split
http://blog.csdn.net/ACMaker/archive/2008/10/29/3176910.aspx http://cgm.cs.mcgill.ca/~orm/rotcal.frame.html History:

In 1978, the paper "Computational Geometry", M.i Shamos's Ph.D, marked the birth of this field of computer science. What he was doing was a very simple algorithm for finding the diameter of a convex polygon, which is determined by the maximum value of a pair of points of a polygon.
Later, the diameter evolved to be determined by a pair of pairs of heel points. Shamos presents a simple O (n) time algorithm to determine the pair of heel points for a convex n-angle shape. Because they have at most only 3n/2, the diameter can be calculated in O (n) time.
As Toussaint later proposed, the Shamos algorithm is like rotating a pair of jams around a polygon. So there is the term "spin jam". In 1983, Toussaint published a paper that uses the same techniques to solve many problems. Since then, the new algorithm based on this model has been established and solved many problems.

They include: calculate distance convex polygon diameter convex polygon wide convex polygon maximum distance convex polygon minimum distance external rectangle minimum area external rectangle minimum perimeter external rectangle triangular split onion triangular split helical triangular split quadrilateral polygon attribute combined convex hull finding common tangent convex polygon intersection critical tangent convex Polygon Vector and thinnest cross section

Convex polygon Diameter We define the maximum distance between any two points on a polygon as the diameter of the polygon. It is possible to determine the point logarithm of this diameter by more than one pair. In fact, for polygons with n vertices, there may be n pairs of "diameter point pairs".

A simple example of a polygon diameter is shown in the figure on the left. The diameter point pairs are shown as black dots (red pairs of parallel lines) that are crossed by parallel lines in the diagram. The diameter is highlighted in light blue.
Obviously, it is not possible to determine the point pair of a convex polygon   p  diameter inside the polygon   p . So the search should be done on the border. In fact, because the diameter is determined by the farthest distance of the polygon's parallel tangent, we only need to query the heel point. Shamos (1978) provides a   O (n)   time complexity algorithm for calculating n-point convex hull pairs of heel points. Diameter by traversing the list of vertices, the maximum distance can be obtained. The following is the pseudo-code for the Shamos algorithm published in the Preparata and Shamos articles in 1985.  
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) does
                         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)
               end
end.

Here Print (p,q) means (p,q) as a pair of heel point to output, area (P,q,r) represents the direction of the Triangle PQR.
Although this process is visually different from conventional rotational jam algorithms, they are essentially the same, and avoid all angles of calculation.

The following is a more intuitive algorithm: computes the endpoint in the Y-direction of the polygon. We call it ymin and Ymax. Construct two horizontal tangents through ymin and Ymax. Since they are already a pair of heel points, calculate the distance between them and maintain a current maximum value. Rotate two lines at the same time until one of them coincides with one edge of the polygon. A new pair of heel points is produced at this time. Calculates the new distance, and compares it with the current maximum, which is newer than the current maximum value. Repeat steps 3 and 4 until the heel pair (Ymin,ymax) is produced again. The output determines the heel point pair for the maximum diameter. At this point, the above procedure (in pseudocode) is very useful, and we can get other information, such as the width of the polygon, from the pair of heel points.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.