Convex hull algorithm for planar circle

Source: Internet
Author: User

Convex hull algorithm for planar circle

We've discussed this interesting question before:

There are several circles on the plane that contain the intersection of all the convex sets of these circles.

Based on the results discussed earlier, it is wrong to do a scan line directly by the center of the circle. We need to consider whether each point on the circle can be part of the convex hull.

However, the number of points on the circle is infinitely large. We need to use the idea of discretization: because we find that the convex hull must be composed of several arcs and segments. and the line segment must be a tangent segment. Thus, we only need to remove each 22 circle tangent to find a convex hull. Obviously, the tangent segments appearing on the convex hull are bound to appear in the tangent convex package, while the remaining segments in the tangent convex package must be arc strings.

However, this algorithm needs to enumerate the tangents between each of the two circles.

But actually, are there really so many points to use?

Obviously not.

The complete pointcut information is too redundant and an attempt is made to describe the convex hull with a circle.

If there is a half-plane that contains all the circles and a circle B tangent, and the direction from circle a points to circle B, we call AB a convex edge, so that we can represent the entire convex hull in a series of circles.

We set \ (h\) for this final sequence, then for any \ (i\) less than the sequence length ( h_ih_{i+1}\) is the edge of the convex hull; the arc on \ (h_i\) between and tangent \ (h_ih_{i+1}\) is also part of the convex package.

Next, we consider the upper bound of the sequence length, which is also the upper bound of the tangent and the number of arcs in the convex hull;

Obviously the sequence \ (h\) has the following properties:

    1. Each of the adjacent two elements is not equal;
    2. There is no subsequence such as \ (\cdots a\cdots B \cdots a\cdots b\cdots\)

We can prove that any integer sequence length that satisfies the above two properties of a range of 1~n will not exceed \ (2n-1\)

证明:    设一个存在长度为2n+d的序列,满足性质一二。其中d为非负整数。    如果该序列未出现1~n中某一个元素,则将2n个元素中的重复元素换成未出现的元素,直到每一种元素都出现。经过了这一过程,序列一定仍然合法。    之后,序列中一定有n个互不相同的元素。剩下的另外n+d的个中,假设最多有m个互相不同的。    我们将两两相同的元素之间都连一条线,显然这些线之间可以有包含关系,但是不能交错。对于这些只有包含和不相交关系的区间,我们可以插入n-m个元素,来保证其相同的元素都被隔开。但是实际上我们会有n+d-m+1个相同元素相邻。显然是不可能合法的。这与原设矛盾。    综上所述,2n-1是序列长度的一个上界。

We guarantee that for any n circle, the convex hull sequence length is less than 2N, then how to calculate the convex hull of the whole set S?

Considering that if we have calculated the two convex sequences of the p set and the Q set, in order to merge two sequences, we simply need to judge the outer circle at any time by using the same half-plane as the rotation jam, with the same two-direction tangent to the separate and p,q, so as to construct a new sequence.

Along this line of thinking, we consider divide and conquer:

//构造集合S的凸包序列;序列 分治( 圆集合 S ) {  1 ) {    返回 S中唯一元素单独组成的序列;  }  将S集合按任意的顺序分成大小最多相差1的不相交的两个子集P,Q;  序列 A = 分治(P), B = 分治(Q);  序列 Final = 合并(A,B);  返回 Final;}

What? What is this? Easy language??

The pseudo-code of the merge function is as follows:

//合并两个序列的函数;序列 合并( 序列 P, 序列 Q ) {  序列 S = 空;  有向直线 L = 随意, Lp = L平行并且和P序列相切的有向直线, Lq = L平行并且和Q序列相切的有向直线;  序列元素 p = Lp相切的圆,q = Lq相切的圆;  循环(P,Q中存在没有访问过的元素) {    如果(Lp在Lq外侧) {      S序列后面添加p;      更新(L,p,q);    } 否则 {      S序列后面添加q;      更新(L,q,p);    }    Lp = 和L平行的和p相切的有向直线;    Lq = 和L平行的和q相切的有向直线;  }  返回 S;}

The contents of the update function are as follows:

角度 夹角( 有向直线 a, 有向直线 b ) {  如果(b不存在) 返回 无穷大;  返回 有向直线a逆时针旋转到有向线段b的角度;}有向直线 切线( 序列元素 a, 序列元素 b ) {  返回 圆a到圆b的半平面切线;}//将L以及p,q跟新到合适的位置;void 更新( 有向直线& L, 序列元素& x, 序列元素& y ) {  角度 a1 = 夹角(L, 切线(x,y)), a2 = 夹角(L, 切线(x,序列中x的下一个元素));  角度 a3 = 夹角(L, 切线(y,x)), a4 = 夹角(L, 切线(y,序列中y的下一个元素));  如果( a1是a1,a2,a3中最小的 ) {    S序列后面添加x;    如果( a3是a2,a3,a4中最小的 ) {      S序列后面添加y;    }  }  如果(a2 < a4) {     L = 切线(x,序列中x的下一个元素);     x = 下一个元素;   } 否则 {    L = 切线(y,序列中y的下一个元素);     y = 下一个元素;   }}

Here are some notes on the correctness and complexity of the algorithm:

    1. About the update function, because we take the outer circle in the P,q as the first of the sequence parameters, so the first chunk of the judgment can handle the relationship between P and Q;
    2. With regard to complexity, it is clear that, since the s sequence length does not exceed 2n-1, the complexity of the division is \ (T (n) = 2T (N/2) +o (n) =o (n\log n) \)
    3. Because the lower bound of the convex hull algorithm of the point set is Nlogn, and the point-set convex hull algorithm is actually the special case of the problem with infinitesimal radius, so Nlogn is the next term of the problem time complexity.
Postscript

The reason why we don't adopt increment method is that the size of round is different, so it is not convenient to organize the order of inserting circle, and it is difficult to organize the data to delete and delete easily because of the problem that the deletion point is not within continuous interval, while the divide-and-conquer algorithm makes full use of the character of n circle sequence length not exceeding 2n-1 Improved the use of information for rotating jams.

Reference

[1] David Rappaport, A convex hull algorithm for discs, and applications, 1991:173-177

[2] [data deleted] Super brain, 2000:memory access failed-memory access failed

Convex hull algorithm for planar circle

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.