Rotate the cart-minimum distance between convex polygon

Source: Internet
Author: User

 

Given two Convex Polygon that are not connected (that is, not intersecting)PAndQTo find the point at the minimum distance between them (P,Q)(PBelongPAndQBelongQ).

In fact, polygon do not intersect, because the polygon we call contains all vertices inside it. If the polygon intersect, the minimum distance becomes meaningless. However, this is the problem. On the other hand, the minimum distance between the convex polygon vertex pairs exists in the case of intersection and non-intersection.

Back to our main problem: intuitively, the point that determines the minimum distance cannot contain the interior of the polygon. Similar to the maximum distance problem, we have the following conclusions:

Two convex polygonPAndQThe minimum distance between two polygon points is determined by the pair points between the polygon. There are three pair points between them between convex polygon, so there are three possible minimum distance modes:

1. "vertex-vertex"

2. "vertex-edge"

3. "Edge-edge"

In other words, the point to determine the minimum distance is not necessarily a point. The following three legends show the above conclusions:

Through the above conclusion, an algorithm based on the rotating jamming shell is naturally generated:

Considering the following algorithm, the input of the algorithm is a convex polygon p and q with M and N clockwise given vertices respectively.

1. ComputingPUpperYVertex with the smallest coordinate value (calledYminp) AndQUpperYThe vertex with the largest coordinate value (calledYmaxq).

2. PolygonYminpAndYmaxqConstruct two tangent linesLpAndSCSIPlace the corresponding polygon on their right side. In this caseLpAndSCSIHas different directions, andYminpAndYmaxqIt becomes a pair of vertex points between polygon.

3. Calculate the distance (Yminp,YmaxqAnd maintain it as the current minimum value.

4. Rotate parallel lines clockwise at the same time until one of them overlaps with the edges of the polygon.

5. If there is only one line that overlaps with the edge, you only need to calculate the distance between the vertex-edge pair and the vertex-vertex pair. Both of them are compared with the current minimum value. If the current minimum value is smaller than the current minimum value, replace and update. If both tangent and edge overlap, the situation is more complicated. If the edges overlap, that is, you can construct a vertical line (but not at the vertex) that is mutually exceeded with the two edges, then the distance between the edges and edges is calculated. Otherwise, calculate the distance between the three new "vertex-vertex" pair vertex. All these distances are compared with the current minimum value,
If the value is smaller than the current minimum value, it is updated and replaced.

6. Repeat steps 4 and 5 until the new point is (Yminp,Ymaxq).

7. Minimum output distance.

The rotating jamming mode ensures that all pair of embedding points (and all possible sub-cases) are taken into account. In addition, the entire algorithm has a linear time complexity, because (except initialization), only operations with the same number of vertices need to be executed.

The problem of the minimum distance and the maximum distance shows that the rotary jamming model has different usage (compared with the previous problem of diameter and width ). This algorithm can be applied to the problem of two polygon.

The "minimum box" Problem (an external rectangle with the minimum area) shows the application of another rotating jamming case through two orthogonal tangent sets on the same polygon.

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.