Skip to content

Commit

Permalink
Add PolyCut
Browse files Browse the repository at this point in the history
  • Loading branch information
baluteshih committed Oct 13, 2023
1 parent 3b515b5 commit 9dfeaab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions codebook/8_Geometry/PolyCut.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
vector<pdd> cut(vector<pdd> poly, pdd s, pdd e) {
vector<pdd> res;
for (int i = 0; i < SZ(poly); ++i) {
pdd cur = poly[i], prv = i ? poly[i - 1] : poly.back();
bool side = ori(s, e, cur) < 0;
if (side != (ori(s, e, prv) < 0))
res.pb(intersect(s, e, cur, prv));
if (side)
res.pb(cur);
}
return res;
}
2 changes: 2 additions & 0 deletions codebook/content.tex
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ \subsection{VectorInPoly*} % test by qoj 5479
\lstinputlisting{8_Geometry/Vector_in_poly.cpp}
\subsection{PolyUnion*} % test by CF 101673 A
\lstinputlisting{8_Geometry/PolyUnion.cpp}
\subsection{PolyCut}
\lstinputlisting{8_Geometry/PolyCut.cpp}
\subsection{Polar Angle Sort*} % test by NTUJ 2270
\lstinputlisting{8_Geometry/Polar_Angle_Sort.cpp}
\subsection{Half plane intersection*} % test by qoj 2162 (World Finals' problem)
Expand Down

0 comments on commit 9dfeaab

Please sign in to comment.