半平面求交

• Step 1: Separate the h-planes into two sets. One has polar angles of (-½π, ½π], the other has those of (-π, -½π]∪(½π, π].

• 将半平面分成两部分,一部分极角范围(-½π, ½π],另一部分范围(-π, -½π]∪(½π, π] 。

        

Step 2: Consider the set of h-planes in (-½π, ½π] (the other set should also go through step 3 and 4 similarly). Sort them by the polar angle. For the h-planes with the same polar angle, we can keep only one down (delete all others) according to the constant of these h-planes. 

• 考虑(-½π, ½π]的半平面(另一个集合类似地做Step3/4),将他们极角排序。对极角相同的半平面,根据常数项保留其中之一。

        

• Step 3.1: Starting from two h-planes with the least polar angle, compute their intersection. Push them two into a stack. 

• 从排序后极角最小两个半平面开始,求出它们的交点并且将他们压入栈。

        

• Step 3.2: Each time, add one more h-plane by increasing order of polar angles, and calculate the intersection of it and the top h-plane in stack. 

• 每次按照极角从小到大顺序增加一个半平面,算出它与栈顶半平面的交点。

        

• Step 3.3: If this intersection is to the right of the intersection of top two h-planes in stack, we pop the stack once. 

• 如果当前的交点在栈顶两个半平面交点的右边,出栈(pop)。

        

• Step 4.1: Intersections of adjacent h-plane pairs in stack form half a convex polygon. For the two sets, we have two halves – (-½π, ½π] gives an upper hull and (-π, -½π]∪(½π, π] gives a lower hull.

• 相邻半平面的交点组成半个凸多边形。我们有两个点集,(-½π, ½π]给出上半个,(-π, -½π]∪(½π, π]给出下半个。

        

• Step 4.2: At the beginning, four pointers p1, p2, p3 and p4 indicate leftmost/rightmost edges of both upper and lower hulls.

• p1 and p3 move rightwards, while p2 and p4 walks leftwards.

• 初始时候,四个指针p1, p2, p3 and p4 指向上/下凸壳的最左最右边。

• p1, p3向右走,p2, p4向左走。

        

• Step 4.3: At anytime, if the leftmost intersection is against the feasible region provided by p1 or p3, we are sure the leftmost one is to be removed.

• Naturally, p1 or p3 walks rightwards to its adjacent edge. 

• 任意时刻,如果最左边的交点不满足p1/p3所在半平面的限制,我们相信这个交点需要删除。

• p1或p3走向它右边的相邻边 。

        

• The judgment holds analogously for rightmost intersection with p2 and p4. 

• 类似地我们处理最右边的交点。

        

• Step 4.4: Do the above removing repeatedly until there is no more update. 

• 重复运作直到不再有更新出现 - 迭代。


• Everything except sorting (Step 2) in S&I algorithm remain linear – O(n) running time. Usually we use quick-sort. The total complexity is O(nlogn), with fairly small constant factor hidden. 

• 除了Step2中的排序以外,S&I算法的每一步都是线性的。通常我们用快速排序实现Step2,总的时间复杂度为O(nlogn),隐蔽其中的常数因子很小。


http://www.niftyadmin.cn/n/904780.html

相关文章

5分钟学会非对称加密

有非对称加密必然有对称加密,这里对称加密做个背景介绍:数据发送方将明文(原始数据)通过加密密钥进行加密算法处理后,使其变成加密密文发送出去。接收方收到密文后,使用和加密同样的密钥及相同算法的逆算法…

Delaunay三角化

点集的三角剖分(Triangulation),对数值分析(比如有限元分析)以及图形学来说,都是极为重要的一项预处理技术。尤其是Delaunay三角剖分,由于其独特性,关于点集的很多种几何图都和Delau…

exit和return

exit(0)是指程序正常退出 exit(1)是程序非正常退出 对于程序运行而言没有太大区别 主要的作用是使读程序的人了解这点。 return 1 或 return -1 表示程序运行错误。 转载于:https://www.cnblogs.com/claudia529/p/10794291.html

数据存储 Json

数据存储 Json 一、JsonLInesEx 1 from scrapy.exporters import JsonLinesItemExporter2 class JsonLinesItemExporterPipeline(object):3 def __init__(self):4 self.file open(jsonfile.json, wb) # 必须写入二进制5 self.exporter JsonLinesItemExp…

矩阵运算概要

提到矩阵,相信大家都不陌生,作为最基本的数学概念之一,我们 知道常用的矩阵运算包括:矩阵加减乘、行列式、转置矩阵、逆矩阵、特征向量(特征值)。 具体概念不做过多讲讲,直接上代码&#xff08…

Elasticsearch 简介

Elasticsearch 简介转载于:https://www.cnblogs.com/guozepingboke/p/10795427.html

四元数定义三维旋转

四元数(Quaternion)是由爱尔兰数学家 哈密顿(Hamilton)在1843年发明的概念。四元数的乘法不符合交换律(commutative law)。 四元数 可以描述为 (x * i, y * j, z * k, w) ,其中(x,y,z&#x…

F-神殿-2018年第二届河北省大学生程序设计竞赛(位运算)

icebound通过勤工俭学,攒了一小笔钱,于是他决定出国旅游。这天,icebound走进了一个神秘的神殿。神殿由八位守护者守卫,总共由 6464 64个门组成,每一道门后都有一个迷宫,迷宫的大小均为 100100100 \times 10…