File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change 1-
21/**
32 * Author: chilli
43 * Date: 2019-05-05
@@ -31,16 +30,15 @@ vector<P> halfPlaneIntersection(vector<Line> vs) {
3130 vector < Line > deq (sz (vs ) + 5 );
3231 vector < P > ans (sz (vs ) + 5 );
3332 deq [0 ] = vs [0 ];
34- int ah = 0 , at = 0 ;
35- #define fix (a , b ) \
36- while (ah<at && sideOf(sp(a),ans[at-1]) < 0) at--;\
37- while (ah<at && sideOf(sp(b),ans[ah]) < 0) ah++;\
38- ans[at++] = lineInter(sp(a), sp(deq[at])).second;
39- rep (i ,1 ,sz (vs )){
33+ int ah = 0 , at = 0 , n = sz (vs );
34+ rep (i ,1 ,n + 1 ) {
35+ if (i == n ) vs .push_back (deq [ah ]);
4036 if (angDiff (vs [i ], vs [i - 1 ]) == 0 ) continue ;
41- fix (vs [i ], vs [i ]); deq [at ] = vs [i ];
37+ while (ah < at && sideOf (sp (vs [i ]),ans [at - 1 ]) < 0 ) at -- ;
38+ while (i != n && ah < at && sideOf (sp (vs [i ]),ans [ah ])< 0 ) ah ++ ;
39+ ans [at ++ ] = lineInter (sp (vs [i ]), sp (deq [at ])).second ;
40+ deq [at ] = vs [i ];
4241 }
43- fix (deq [ah ], deq [at ]);
4442 if (at - ah <= 2 ) return {};
4543 return {ans .begin () + ah , ans .begin () + at };
4644}
You can’t perform that action at this time.
0 commit comments