其他分享
首页 > 其他分享> > 凸包简介 - Convex Hull

凸包简介 - Convex Hull

作者:互联网

Convex Hull

Problem Definition

Given: A set \(Z\) of \(n\) points in the plane.

Find: Smallest convex set containing \(Z\).

Some Basic Definition

  1. A set \(S\) in the plane is convex iff for every pair of points \(p_1\) and \(p_2\) in \(S\), the line-segment $p_1p_2 $ is in \(S\).
  2. A point \(p\) in a convex set \(S\) is said to be extreme (or a
    corner) iff no segment \(ab\) in \(S\) has \(p\) in its interior.
  3. \(CH(Z)\) is considered determined once its corners ordered around the boundary are found.
  4. Simplifying assumptions: No pair of Z-points has the same x- or y-coordinate and/or no three points colinear.

Equivalent Formulations for CH

Sorting can be transformed in \(O(n)\) time into the convex hull problem. Thus the upper bound of the complexity of CH is same as sorting which is \(O(n\log n)\).

Point \(p_1,p_2,p_3\) make a right turn at \(p_2\) iff \(p_3\) is to the right or on the line through \(p_1\) and \(p_2\). Otherwise \(p_1,p_2,p_3\) make a left turn at \(p_2\). Mathematically speaking, if:

\[det\begin{bmatrix} x_1 & y_1 & 1\\ x_2 & y_2 & 1\\ x_3 & y_3 & 1 \end{bmatrix}>0 \Rightarrow \textit{left turn} \]

Algorithm 1: Point Pruning

Since: A \(Z\)-point which is not a corner is inside a triangle on \(Z\).

Then, we need to sort the corners.

Algorithm 2: Edge Pruning → Jarvis March (1973)

Naïve approach:

Jarvis's March:

Algorithm 3: Graham's Scan (1972)

Procedure:

  1. Sort points around some point of CH(Z). Points at the same angle are sorted by their distance. Construct the polygon defined by the sorting.
  2. Prune the nodes. If we transverse the nodes in counterclockwise (ccw) order, all middle nodes should make a left turn for pairs \(p+,p,p-\), otherwise it can be removed. After remove the middle point \(p\), \(p-\) would go backward, otherwise all three points walk forward.
  3. Algorithm terminate when the initial corner arrived by a forward step.

Something may goes wrong:

Complexity:

Algorithm 4: Divide and Conquer

Partition \(Z\) into balanced subsets \(Z_1\) and \(Z_2\), determine \(CH(Z_1)\) and \(CH(Z_2)\) recursively. The problem solve directly if \(n\leq 2\).

Merge:

Partition and union complexity:

\[\begin{array}{c} T(n)=O(1), n \leq 2 \\ T(n)=2 * T(n / 2)+O(n), n>2 \end{array} \]

Overall \(O(n\log n)\).

Algorithm 5: Marriage-before-Conquest (1986)

“Reverse Order” than Divide-and-Conquer.

Calculate the Upper and Lower Convex Hulls separately and merge them.

  1. Divide the nodes into 2 points, which is approximately same.
  2. Find the Bridge across two sides.
  3. Drop the nodes exactly below the bridge and compute the left upper CH and right upper CH recursively.
  4. Merge.

How to find a Bridge?

  1. Build edges by pairing two nodes arbitrarily. Select the edge \(e\) with median slope.
  2. Move \(e\) parallelly to the upper/lower extreme point \(p\) (no more higher /lower nodes exists). If exactly two nodes from both sides located in same line, the line is bridge and then be returned.
  3. Otherwise, for all of other points \(p_i\) in same side of \(p\), calculate the slope \(e_i=(p,p_i)\) . If \(p\) is on left side and \(e_i>e\), drop \(p_i\), or if \(p\) is on right side and \(e_i<e\), drop \(p_i\).
  4. Repeat until only 1 node in opposite side of \(p\) exists.

Complexity containing both Bridge Finding, and Overall Complexity is shown as follows, big constant.

Algorithm 6: Chan's

Algorithms with complexity measured as a function of both \(n\) and output size \(h\) are said to be output-sensitive.

Let \(P\subset E^2\) be a set of \(n\geq 3\) points. The procedure of Chan's algorithm is:

Algorithm Hull2D(\(P, m, H\)), where \(P \subset E^2\), \(3 ≤ m ≤ n\), and \(H ≥ 1\)

  1. partition \(P\) into subsets \(P_1,\cdots,P_{\lceil n/m\rceil}\) each of size at most \(m\)
  2. for \(i=1,\cdots, \lceil n/m\rceil\) do
    1. compute conv(\(P_i\)) by Graham's scan and store its vertices in an array in ccw order
  3. \(p_0\leftarrow (0,-\infty)\)
  4. \(p_1\leftarrow\) the rightmost point of \(P\)
  5. for \(k=1,\cdots,H\) do
    1. for \(i=1,\cdots,\lceil n/m\rceil\) do
      1. compute the points \(q_i\in P_i\) that maximizes \(\angle p_{k-1}p_kq_i\quad (q_i\neq p_k)\) by performing a binary search on the vertices of conv(\(P_i\))
    2. \(p_{k+1}\rightarrow\) the point \(q\) from \(\{q_1,\cdots,q_{\lceil n/m\rceil}\}\) that maximizes \(\angle p_{k-1}p_kq\)
    3. if \(p_{k+1}=p_1\) then return the list \(\langle p_1,\cdots,p_k\rangle\)
  6. return incomplete

By choosing \(m = H\), the complexity of the algorithm is then \(O(n(1+H/m) \log m) = O(n \log H)\). Since the value of \(h\) is not known in advance, we use a sequence of \(H\)’s to “guess” its value as shown below:

Algorithm Hull2D(\(P\)), where \(P \subset E^2\)

  1. for $t = 1, 2,\cdots $ do
    1. $L\rightarrow $ Hull2D(\(P,m,H\)), where \(m=H=\min\{2^{2^t},n\}\)
    2. if \(L\neq incomplete\) then return \(L\)

The procedure stops with the list of hull vertices as soon as the value of \(H\) in the for-loop reaches or exceeds \(h\). The number of iterations in the loop is \(\lceil \log \log h\rceil\) (using base-2 logarithms), and the \(t\)-th iteration takes \(O(n \log H) = O(n2^t )\) time. Therefore, the total running time of the algorithm is \(O(\sum_{t=1}^{\lceil \log\log h\rceil}n2^t)=O(n2^{\lceil\log\log h\rceil+1})=O(n\log h)\). The storage requirement is clearly linear.

Reference:

标签:CH,log,point,Hull,edge,凸包,points,Convex,corners
来源: https://www.cnblogs.com/romaLzhih/p/14408092.html