Rotating jamming case -- convex polygon diameter

Source: Internet
Author: User
Convex Polygon diameter

We define the maximum distance between any two points on a polygon as the diameter of the polygon. The number of vertices that determine the diameter may be more than one pair. In factNPolygon of a vertex may haveNThere is a "diameter point.

 

A simple example of a polygon diameter is shown in the left figure. The diameter point is shown as the Black Point (a red parallel line) that is passed by parallel lines in the figure. The diameter is highlighted in light blue.


Apparently, determine a convex polygonPThe point of diameter cannot be in a polygon.PInternal. Therefore, the search should be performed on the boundary. In fact, because the diameter is determined by the maximum distance of the parallel tangent of the polygon, we only need to query the vertex. Shamos (1978) providesO (N)Time Complexity calculation of n-point convex Packet PairsAlgorithm. Diameter: traverse the vertex list to obtain the maximum distance. As shown in the following table: Preparata and shamos published in 1985ArticlePseudo-shamos Algorithm inCode.
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.

HerePrint (p, q)Indicates(P, q)As a pair of vertex-to-output,Area (P, Q, R)TrianglePqrOf the forward area.
Although this process is different from the conventional rotary jamming algorithm, they are essentially the same and avoid all angle calculations.

The following is a more intuitive algorithm:

    1. Calculate a polygonYThe endpoint in the direction. We call itYminAndYmax.
    2. PassYminAndYmaxConstruct two horizontal tangent lines. Since they are already pair of vertex, the distance between them is calculated and maintained as the current maximum value.
    3. Rotate two lines at the same time until one of them overlaps with one side of the polygon.
    4. A new pair of vertex points is generated at this time. Calculate the new distance and compare it with the current maximum value. If it is greater than the current maximum value, it is updated.
    5. Repeat steps 3 and 4 until a pair of vertex points is generated again.(Ymin, Ymax).
    6. Output a pair of vertices that determine the maximum diameter.

So far, the above process (in pseudo-code) is very useful. We can get other information from the trim point, such as the width of the polygon.

 

 

Http://cgm.cs.mcgill.ca /~ Orm/diam.html

 

Please indicate the source for reprinting. Thank you!

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.