The minimum distance between two convex polygons---两个凸包之间的最短距离---旋转卡壳法
2012-07-30 14:54
639 查看
声明:本文章转自http://cgm.cs.mcgill.ca/~orm/mind2p.html
译文详见:http://blog.csdn.net/acmaker/article/details/3178696
Q, the goal is to find the pair(s) of points (p,q) (p belonging toP andq toQ) 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 byanti-podal pair between the polygons. As there are three cases foranti-podal
pairs between convex polygons, three cases for the minimum distance can occur:
The vertex-vertex case
The vertex-edge case
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 polygonsP andQ with
m and n vertices respectively given in clockwise order.
Compute the vertex with minimum y coordinate for P (call ityminP) and the vertex with maximumy coordinate forQ (call it
ymaxQ).
Construct two lines of support LP and LQ for the polygons atyminP andymaxQ such that the polygons lie to the right of their respective lines of support. ThenLP andLQ have opposite direction, andyminP
and ymaxQ form an anti-podal pair between the polygons.
Compute dist(yminP,ymaxQ) and keep it as the minimum.
Rotate the lines clockwise until one of them coincides with an edge of its polygon.
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.
Repeat steps 4 and 5, until the lines reach (yminP, ymaxQ) again.
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.
译文详见:http://blog.csdn.net/acmaker/article/details/3178696
The minimum distance between two convex polygons
Given two disjoint (i.e. non-intersecting) convex polygons P andQ, the goal is to find the pair(s) of points (p,q) (p belonging toP andq toQ) 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 byanti-podal pair between the polygons. As there are three cases foranti-podal
pairs between convex polygons, three cases for the minimum distance can occur:
The vertex-vertex case
The vertex-edge case
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 polygonsP andQ with
m and n vertices respectively given in clockwise order.
Compute the vertex with minimum y coordinate for P (call ityminP) and the vertex with maximumy coordinate forQ (call it
ymaxQ).
Construct two lines of support LP and LQ for the polygons atyminP andymaxQ such that the polygons lie to the right of their respective lines of support. ThenLP andLQ have opposite direction, andyminP
and ymaxQ form an anti-podal pair between the polygons.
Compute dist(yminP,ymaxQ) and keep it as the minimum.
Rotate the lines clockwise until one of them coincides with an edge of its polygon.
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.
Repeat steps 4 and 5, until the lines reach (yminP, ymaxQ) again.
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.
相关文章推荐
- poj 3608(旋转卡壳求解两凸包之间的最短距离)
- POJ 3608 Bridge Across Islands(旋转卡壳 求不相交凸包之间的最短距离)
- poj 3608(旋转卡壳求解两凸包之间的最短距离)
- Data Structure Array: Find the minimum distance between two numbers
- [html] PHP使用Google map web services来计算两点间的距离 -- Compute the distance between two place via Google map services in PHP
- 旋转卡壳求两个凸包最近距离poj3608
- POJ 3608 Bridge Across Islands(两个凸包最近距离,旋转卡壳)
- poj 3608 Bridge Across Islands(旋转卡壳求凸包最短距离)
- 计算两点间的距离 Calculating the Distance Between Two Points
- poj 3608 Bridge Across Islands 旋转卡壳(两个凸包的最近距离)
- POJ 3608 Bridge Across Islands(旋转卡壳,两凸包最短距离)
- [CareerCup] 18.5 Shortest Distance between Two Words 两单词间的最短距离
- 旋转卡壳--凸包之间的最大距离
- POJ 3862 Asteroids(两个三维凸包的重心到表面最短距离和)
- poj2187 凸包上的最远点对的距离(凸包+旋转卡壳)
- [hoj 2742]The Shape of Donggua[凸包][Graham Scan][旋转卡壳]
- Android – Distance between two points on the Earth
- 求凸包+旋转卡壳算法——求平面点集S内点对的最远距离
- POJ2187 Beauty Contest(旋转卡壳,求凸包中任意两点的距离)
- [leetcode 244] Shortest Word Distance II------------字典中两个字符串的最短距离