Merge convex hull
Consider the following question: what is the Minimum Convex Polygon that contains two convex polygon? The answer is the convex polygon obtained after the convex hull is merged.
The merge convex hull can be implemented in an inefficient way: all vertices of two polygon are given and the convex hull corresponding to these points is calculated. A more efficient method exists. It depends onBridge. Describes this concept:
Two non-Intersecting convex polygon. The merged convex hull contains the convex hull chains (blue thick line on the way) in two polygon, which are connected through the bridge between polygon (blue dotted line on the way)
Given two non-Intersecting polygon, there are two bridges between the polygon. A polygon has the same number of bridges as the number of vertices, as shown in:
Two Intersecting convex polygon. The merge convex hull only contains the bridge between polygon (as shown in the dotted line ). There are eight bridges connected to eight vertices.
The core of merge operations is the sub-governance method. It is also used in polygon. A very simple way to obtain a convex packet is to divide the point set into two parts, calculate the convex packets of two smaller sets, and merge them. Each set is split again until the number of elements is small enough (for example, three or fewer), so the convex hull can be easily obtained.
Toussaint proposed to use the rotating jamming case to find the bridge between two convex polygon. The main advantage of this method is that it uses backtracking and polygon can overlap (OtherAlgorithmThe polygon must be non-Intersecting ). The following is the main process of his algorithm:
Given Convex PolygonP= {P(1 ),...,P(M)} AndQ= {Q(1 ),...,Q(N)}, A point (P(I),Q(J) FormPAndQWhen and only when:
- (P(I),Q(J) To form a parallel vertex.
- P(I-1 ),P(I+ 1 ),Q(J-1 ),Q(J+ 1) All are located (P(I),Q(J) The same side of the line.
Assuming that the polygon is given in the standard form and the vertices are arranged in clockwise order, the algorithm is as follows:
- Separate CalculationPAndQMaximumYCoordinates. If more than one such vertex existsXThe largest coordinate.
- Construct the flat tangent of these points, and place the polygon in the positive direction on the right (so they pointXIn the positive direction of the axis ).
- At the same time, rotate the two tangent clockwise until one of them is at the intersection of the edge. Get a new merge vertex (P(I),Q(J)). In the case of a parallel edge, three parallel vertex are obtained.
- For all valid parallel vertex (P(I),Q(J): DeterminesP(I-1 ),P(I+ 1 ),Q(J-1 ),Q(J+ 1) are all at the connection point (P(I),Q(J) To form the same side of the line. If yes, this parallel point forms a bridge and marks it.
- Repeat steps 3 and 4 until the tangent returns to their original position.
- All possible bridges have been confirmed at this time. The merged convex hull is constructed by continuously connecting the corresponding convex hull chains between bridges.
The above conclusions confirm the correctness of the algorithm. The running time is subject to steps 1, 5, and 6. They allO (N)Run Time (NIs the total number of vertices ). Therefore, the algorithm has the current time complexity.
The bridge between a convex polygon actually determines another useful concept: the public tangent between polygon. Bridge is also the core algorithm for calculating Convex Polygon intersection.
Http://cgm.cs.mcgill.ca /~ Orm/mergech.html
Please indicate the source for reprinting. Thank you!