MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / cut_polygon

Function cut_polygon

code/geometry/polygon.cpp:21–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19 in = !in;
20 return in ? -1 : 1; }
21pair<polygon, polygon> cut_polygon(const polygon &poly,
22 point a, point b) {
23 polygon left, right; point it;
24 for (int i = 0, cnt = poly.size(); i < cnt; i++) {
25 point p = poly[i], q = poly[i == cnt-1 ? 0 : i + 1];
26 if (ccw(a, b, p) < EPS) left.push_back(p);
27 if (ccw(a, b, p) > -EPS) right.push_back(p);
28 if (intersect(a, b, p, q, it, false, true))
29 left.push_back(it), right.push_back(it); }
30 return {left,right}; }
31// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 4

ccwFunction · 0.85
push_backMethod · 0.80
intersectFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected