Skip to content

Commit d283267

Browse files
committed
Updated description and such
1 parent 81f9cd3 commit d283267

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

content/geometry/HalfPlane.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* Date: 2019-05-05
55
* License: CC0
66
* Source: https://github.com/zimpha/algorithmic-library/blob/master/computational-geometry/polygon.cc
7-
* Description: Computes the intersection of a set of half-planes.
7+
* Description: Computes the intersection of a set of half-planes. Input is given as a set of planes, facing left.
8+
* Output is the convex polygon representing the intersection. The points may have duplicates and be collinear.
89
* Time: O(n \log n)
910
* Status: fuzz-tested, submitted on https://maps19.kattis.com/problems/marshlandrescues
1011
* Usage:
@@ -41,5 +42,6 @@ vector<P> halfPlaneIntersection(vector<Line> vs) {
4142
while (ah<at && sideOf(sp(deq[ah]),ans[at-1]) < 0) at--;
4243
while (ah<at && sideOf(sp(deq[at]),ans[ah]) < 0) ah++;
4344
ans[at++] = lineInter(sp(deq[ah]), sp(deq[at])).second;
45+
if (at - ah <= 2) return {};
4446
return {ans.begin() + ah, ans.begin() + at};
4547
}

fuzz-tests/geometry/HalfPlane.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ void testRandom() {
229229
}
230230

231231
int main() {
232-
// test1();
233-
// testInf();
234-
// testLine();
232+
test1();
233+
testInf();
234+
testLine();
235235
testPoint();
236-
// testEmpty();
237-
// testRandom();
238-
// Failure case for MIT's half plane code
236+
testEmpty();
237+
testRandom();
238+
// Failure case for MIT's half plane cod
239239
// vector<Line> t({{P(9, 8), P(9, 1)}, {P(3, 3), P(3, 5)}, {P(7, 6), P(0, 8)}});
240240
// addInf(t);
241241
// cout << polygonArea2(halfPlaneIntersection(t)) << endl;

0 commit comments

Comments
 (0)