Skip to content

Commit 4149c07

Browse files
committed
Updated with current version
1 parent e61acd5 commit 4149c07

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

content/geometry/HalfPlane.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ vector<P> halfPlaneIntersection(vector<Line> vs) {
4040
while (i!=n && ah<at && sideOf(sp(vs[i]),ans[ah])<0) ah++;
4141
auto res = lineInter(sp(vs[i]), sp(deq[at]));
4242
if (res.first != 1) continue;
43-
mxErr1 = max(mxErr1, (lineDist(sp(vs[i]), res.second)));
44-
mxErr2 = max(mxErr2, (lineDist(sp(vs[i]), lineInter2(sp(vs[i]), sp(deq[at])))));
45-
assert((res.second - lineInter2(sp(vs[i]), sp(deq[at]))).dist() < 1e-8);
46-
// ans[at++] = res.second;
47-
ans[at++] = lineInter2(sp(vs[i]), sp(deq[at]));
43+
ans[at++] = res.second;
4844
deq[at] = vs[i];
4945
}
5046
if (at - ah <= 2) return {};

content/geometry/lineDistance.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Returns the signed distance between point p and the line containing points a and
1010
\begin{minipage}{15mm}
1111
\includegraphics[width=\textwidth]{content/geometry/lineDistance}
1212
\end{minipage}
13-
* Status: tested
13+
* Status: tested
1414
*/
1515
#pragma once
1616

content/geometry/lineIntersection.h

+12-14
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
* Source: https://vlecomte.github.io/cp-geo.pdf
66
* Description:\\
77
\begin{minipage}{75mm}
8-
If a unique intersection point of the lines going through s1,e1 and s2,e2 exists {1, point} is returned. If no intersection point exists {0, (0,0)} is returned and if infinitely many exists {-1, (0,0)} is returned. The wrong position will be returned if P is Point<ll> and the intersection point does not have integer coordinates. Products of three coordinates are used in intermediate steps so watch out for overflow if using int or long long.
9-
\end{minipage}
8+
If a unique intersection point of the lines going through s1,e1 and s2,e2 exists {1, point} is returned. If no
9+
intersection point exists {0, (0,0)} is returned and if infinitely many exists {-1, (0,0)} is returned. The wrong
10+
position will be returned if P is Point<ll> and the intersection point does not have integer coordinates. Products of
11+
three coordinates are used in intermediate steps so watch out for overflow if using int or long long. \end{minipage}
1012
\begin{minipage}{15mm}
1113
\includegraphics[width=\textwidth]{content/geometry/lineIntersection}
1214
\end{minipage}
@@ -20,17 +22,13 @@ If a unique intersection point of the lines going through s1,e1 and s2,e2 exists
2022

2123
#include "Point.h"
2224

23-
template<class P>
24-
pair<int, P> lineInter(P s1, P e1, P s2, P e2) {
25-
auto d = (e1-s1).cross(e2-s2);
26-
if (d == 0) //if parallel
27-
return {-(s1.cross(e1, s2)==0 || s2==e2), P(0,0)};
28-
else
29-
return {1, s2-(e2-s2)*s1.cross(e1, s2)/d};
30-
}
25+
template <class P> pair<int, P> lineInter(P s1, P e1, P s2, P e2) {
26+
auto d = (e1 - s1).cross(e2 - s2);
27+
if (d == 0) // if parallel
28+
return {-(s1.cross(e1, s2) == 0 || s2 == e2), P(0, 0)};
29+
else {
3130

32-
template<class P> P lineInter2(P p1, P p2, P q1, P q2) {
33-
double a1 = q1.cross(q2, p1), a2 = -q1.cross(q2, p2);
34-
auto res = (p1 * a2 + p2 * a1) / (a1 + a2);
35-
return res;
31+
double a1 = s2.cross(e2, s1), a2 = -s2.cross(e2, e1);
32+
return {1, (s1 * a2 + e1 * a1) / (a1 + a2)};
33+
}
3634
}

fuzz-tests/geometry/HalfPlane

724 KB
Binary file not shown.

0 commit comments

Comments
 (0)