
264
|
第
9
章
rightA = node.getRightAncestor()
if rightA is None:
return
right = rightA.getSmallestRightDescendant()
#
完整性检查,必须是不同的点。
if left.site == right.site:
return
#
如果两条边没有有效的交点
,
那么返回。
p = leftA.edge.intersect(rightA.edge)
if p is None:
return
radius = ((p.x - left.site.x) ** 2 + (p.y - left.site.y) ** 2) ** 0.5
#
确保从外接圆中选择最低的点。
circleEvent = Event(Point((p.x, p.y - radius)))
if circleEvent.p.y >= self.sweepPt.y:
return
node.circleEvent = circleEvent
circleEvent.node = node
heappush(self.pq, circleEvent)
9.6.3 算法分析
Fortune
扫描算法
的性能和插入优先队列的事件数息息相关。首先,必须插入
n
个点。
之后在处理的过程中,每个新的基址点至多会生成两条新的弧,因此海岸线最多会含有
2*n
-
1
条弧。通过使用二叉树来存储海岸线的状态 ...