| 19 | in = !in; |
| 20 | return in ? -1 : 1; } |
| 21 | pair<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: |