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 版)
计算几何
237
计算几何
9.3 凸包扫描
Andrew
发明的
凸包扫描
算法(
1979
)将整个问题分成两个部分:构建一个上凸包和一
个下凸包;将它们组合起来。首先,点集
P
中的所有点按照
x
坐标排序(
x
坐标相同时,
按照
y
坐标排序)。我们从
P
中的最左边两个点开始构建上凸包,然后就此扩展
凸包扫
算法,首先要在
P
中找到这样一个点
p
p
P
,满足排序后,其前一个位置即上凸
包的最后一个点
L
i
。用类似的方法构建下凸包,然后将其与上凸包加以合并,得到最终
结果。
找到点
p
之后,如果
L
i
-1
L
i
p
这三个点组成的两条线段形成了一个右拐的线条,那
凸包扫描
算法会把点
p
加入上凸包(或者下凸包)中。这等价于计算图
9-2
3
×
3
阵的行列式,也就是计算叉积。如果
cp
< 0
,那么这三个点组成的线段形成了一个右拐
的线条
凸包扫描
算法继续进行。但是如果
cp
= 0
(即三点共线)或者
cp
> 0
(三点组
成的线段形成了一个左拐的线条),那么中间的点
L
i
将被从凸包中删除,因为这和凸多
边形的性质相冲突。计算出下凸包的思想与此类似,算法最后会将这两个凸包合并在一起。
9-2:检查这三个点是否组成右拐的线条
凸包扫描算法小结
最好情况、平均情况和最坏情况:
O(
n
log
n
)
convexHull (P)
sort P ascending by x coordinate (break ties by sorting y)
if n < 3 then return P
upper = {p0, p1}
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