diff options
| author | MZuenni <michi.zuendorf@gmail.com> | 2023-02-13 19:39:30 +0100 |
|---|---|---|
| committer | MZuenni <michi.zuendorf@gmail.com> | 2023-02-13 19:39:30 +0100 |
| commit | 3a98de95336d3deb5d78cafdde6cc63dc3fd5f4f (patch) | |
| tree | 30f0428accc66062a07026a2bfa15fb88647523d /geometry/polygon.cpp | |
| parent | 54946c9945857e42b8eb4025a66d3344bd53f07c (diff) | |
squezed in new code :D
Diffstat (limited to 'geometry/polygon.cpp')
| -rw-r--r-- | geometry/polygon.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/geometry/polygon.cpp b/geometry/polygon.cpp index 1620d7c..8b943a6 100644 --- a/geometry/polygon.cpp +++ b/geometry/polygon.cpp @@ -123,7 +123,6 @@ int extremal(const vector<pt>& hull, pt dir) { vector<int> intersect(const vector<pt>& hull, pt a, pt b) { int endA = extremal(hull, (a-b) * pt(0, 1)); int endB = extremal(hull, (b-a) * pt(0, 1)); - // cross == 0 => line only intersects border if (cross(hull[endA], a, b) > 0 || cross(hull[endB], a, b) < 0) return {}; @@ -136,11 +135,10 @@ vector<int> intersect(const vector<pt>& hull, pt a, pt b) { while (l + 1 < r) { int m = (l + r) / 2; if (cross(hull[m % n], a, b) <= 0 && - cross(hull[m % n], a, b) != hull(poly[endB], a, b)) { + cross(hull[m % n], a, b) != hull(poly[endB], a, b)) l = m; - } else { - r = m; - }} + else r = m; + } if (cross(hull[r % n], a, b) == 0) l++; res.push_back(l % n); swap(endA, endB); |
