Skip to Content
アルゴリズムクイックリファレンス 第2版
book

アルゴリズムクイックリファレンス 第2版

by George T. Heineman, Gary Pollice, Stanley Selkow, 黒川 利明, 黒川 洋
December 2016
Intermediate to advanced
440 pages
9h 44m
Japanese
O'Reilly Japan, Inc.
Content preview from アルゴリズムクイックリファレンス 第2版
9.4
 線分交差を計算する
293
9.4
 線分交差を計算する
2
次元平面で線分の集合
S
が与えられたとき、すべての線分間の交点の全集合を
決定する必要がある。図9-6の例では、
4
つの線分に(黒丸で示された)交点が
2
ある。例9-2のように、力任せの方式だと、
S
に含まれる線分間すべての交点を計
算するので、
C(n, 2)
、すなわち
n*(n
1)/2
個の交点の計算を行い、
O(n
2
)
時間か
かる。線分の各対について、交点を(もしあるなら)出力する。
図9-6 2 つの交点を持つ 4つの線分
9-2
 力任せ交点計算の実装
public class BruteForceAlgorithm extends IntersectionDetection {
public Hashtable<IPoint, List<ILineSegment[]>> intersections
(ILineSegment[] segments) {
initialize();
for (int i = 0; i < segments.length-1; i++) {
for (int j = i+1; j < segments.length; j++) {
IPoint p = segments[i].intersection(segments[j]);
if (p != null) {
record (p, segments[i], segments[j]);
}
}
}
return report;
}
}
この計算には、 ...
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.
Start your free trial

You might also like

Rではじめるデータサイエンス

Rではじめるデータサイエンス

Hadley Wickham, Garrett Grolemund, 黒川 利明, 大橋 真也
プログラミングRust 第2版

プログラミングRust 第2版

Jim Blandy, Jason Orendorff, Leonora F. S. Tindall, 中田 秀基
詳説 イーサネット 第2版

詳説 イーサネット 第2版

Charles E. Spurgeon, Joann Zimmerman, 三浦 史光, 豊沢 聡

Publisher Resources

ISBN: 9784873117850Other