Skip to content

Commit 4df6e0e

Browse files
committed
Fit stuff within 63 columns
1 parent 0a4e8d3 commit 4df6e0e

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

content/geometry/HalfPlane.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ typedef array<P, 2> Line;
2020
#define sp(a) a[0], a[1]
2121
#define ang(a) atan2((a[1] - a[0]).y, (a[1] - a[0]).x)
2222
bool cmp(Line a, Line b) {
23-
auto s = ang(a) - ang(b);
24-
return s == 0 ? sideOf(sp(b), a[0]) >=0 : s < 0;
23+
auto s = ang(a) - ang(b);
24+
return s == 0 ? sideOf(sp(b), a[0]) >= 0 : s < 0;
2525
}
2626
vector<P> halfPlaneIntersection(vector<Line> vs) {
27-
sort(all(vs), cmp);
28-
vector<Line> deq(sz(vs)+5);
29-
vector<P> ans(sz(vs)+5);
30-
int dh = 0, dt = 1, ah=0, at=0;
31-
deq[0] = vs[0];
32-
for (int i = 1; i < sz(vs); ++i) {
33-
if (ang(vs[i]) - ang(vs[i-1]) == 0) continue;
34-
while (ah < at && sideOf(sp(vs[i]), ans[at-1])< 0) at--, dt--;
35-
while (ah < at && sideOf(sp(vs[i]), ans[ah]) < 0) ah++, dh++;
36-
ans[at++] = lineInter(sp(deq[dt-1]), sp(vs[i])).second;
37-
deq[dt++] = vs[i];
38-
}
39-
while (ah < at && sideOf(sp(deq[dh]), ans[at-1]) < 0) at--, dt--;
40-
while (ah < at && sideOf(sp(deq[dt]), ans[ah]) < 0) ah++, dh++;
41-
if (dt-dh <= 2) return {};
42-
ans[at++] = lineInter(sp(deq[dh]), sp(deq[dt-1])).second;
43-
return {ans.begin()+ah, ans.begin()+at};
27+
sort(all(vs), cmp);
28+
vector<Line> deq(sz(vs) + 5);
29+
vector<P> ans(sz(vs) + 5);
30+
int dh = 0, dt = 1, ah = 0, at = 0;
31+
deq[0] = vs[0];
32+
for (int i = 1; i < sz(vs); ++i) {
33+
if (ang(vs[i]) - ang(vs[i - 1]) == 0) continue;
34+
while (ah<at && sideOf(sp(vs[i]),ans[at-1]) < 0) at--,dt--;
35+
while (ah<at && sideOf(sp(vs[i]),ans[ah]) < 0) ah++,dh++;
36+
ans[at++] = lineInter(sp(deq[dt - 1]), sp(vs[i])).second;
37+
deq[dt++] = vs[i];
38+
}
39+
while (ah<at && sideOf(sp(deq[dh]),ans[at-1]) < 0) at--,dt--;
40+
while (ah<at && sideOf(sp(deq[dt]),ans[ah]) < 0) ah++, dh++;
41+
if (dt - dh <= 2) return {};
42+
ans[at++] = lineInter(sp(deq[dh]), sp(deq[dt - 1])).second;
43+
return {ans.begin() + ah, ans.begin() + at};
4444
}

0 commit comments

Comments
 (0)