Skip to Content
算法技术手册(原书第2 版)
book

算法技术手册(原书第2 版)

by George T.Heineman, Gary Pollice, Stanley Selkow
August 2017
Intermediate to advanced
360 pages
8h 35m
Chinese
China Machine Press
Content preview from 算法技术手册(原书第2 版)
计算几何
245
计算几何
算法
经过了实践的检验,它通过关注数据的子集来改善性能。试想一下,使用一条水平
线
L
从上至下扫描线段,然后输出和线段的交点。图
9-7
给出了从上到下扫描时线段
L
的状态。
9-7:寻找 6 条线段的 7 个交点
线段扫描的创新之处在于将所有线段从左至右按照
y
坐标进行排序水平线段被认为左
端点“高于”右端点。线段
只可能和扫描线上的相邻线
段有交点。具体来说,如果两条
线段
S
i
S
j
相交,那么肯定有某个时间点,它们在扫描线上处于相邻位置。
线段扫描算
通过所维护线段的状态来实现交点的高效检测
在仔细地检查图
9-7
的扫描线选择的
9
个位置时,我们会发现这些位置是线段的起点
终点或者交点。
线段扫描
不会真在笛卡儿平面上做“扫描”动作,而是首先在事件队
列中插入线段的
2*n
个端点,这个事件队列是一个优化过的优先队列。所有交点都可以
在处理这些点时找到。
线段扫描算法
处理这个队列,维护
L
的状态并检测
L
上相邻的线
段是否相交。
9.5.1 输入 / 输出
线段扫描算法
处理笛卡儿平面上规模为
n
的线段集
S
S
中可以没有重复的线段。没
有两条线段会共线(也就是说,重叠或者有相同的斜率)。算法可以处理水平或者垂
直线段,但是需要仔细地计算并对线段进行精准的排序线段不能只包含一个点(例如,
一条起点和终点相同的线段)。
输出是
k
个交点(如果存在),以及
S
中相交于交点
P
i
的实际线段
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

Aurélien Géron
Go语言编程

Go语言编程

威廉·肯尼迪

Publisher Resources

ISBN: 9787111562221