summaryrefslogtreecommitdiff
path: root/geometry
diff options
context:
space:
mode:
Diffstat (limited to 'geometry')
-rw-r--r--geometry/formulars.cpp6
-rw-r--r--geometry/linesAndSegments.cpp4
-rw-r--r--geometry/polygon.cpp4
3 files changed, 7 insertions, 7 deletions
diff --git a/geometry/formulars.cpp b/geometry/formulars.cpp
index 855ef1e..37cc4f4 100644
--- a/geometry/formulars.cpp
+++ b/geometry/formulars.cpp
@@ -21,9 +21,9 @@ double norm(pt a) {return dot(a, a);}
double cross(pt a, pt b) {return imag(conj(a) * b);}
double cross(pt p, pt a, pt b) {return cross(a - p, b - p);}
-// -1 => gegen den Uhrzeigersinn
-// 0 => kolliniear
-// 1 => im Uhrzeigersinn.
+// 1 => c links von a->b
+// 0 => a, b und c kolliniear
+// -1 => c rechts von a->b
int orientation(pt a, pt b, pt c) {
double orien = cross(b - a, c - a);
return (orien > EPS) - (orien < -EPS);
diff --git a/geometry/linesAndSegments.cpp b/geometry/linesAndSegments.cpp
index 3a8ac02..4da35b1 100644
--- a/geometry/linesAndSegments.cpp
+++ b/geometry/linesAndSegments.cpp
@@ -39,7 +39,7 @@ double distToLine(pt a, pt b, pt p) {
// Liegt p auf der Geraden a-b? 2d und 3d
bool pointOnLine(pt a, pt b, pt p) {
- return orientation(a, b, p) == 0;
+ return cross(a, b, p) == 0;
}
// Test auf Linienschnitt zwischen a-b und c-d.
@@ -57,7 +57,7 @@ pt lineIntersection(pt p0, pt p1, pt p2, pt p3) {
// Liegt p auf der Strecke a-b?
bool pointOnLineSegment(pt a, pt b, pt p) {
- if (orientation(a, b, p) != 0) return false;
+ if (cross(a, b, p) != 0) return false;
ld dist = norm(a - b);
return norm(a - p) <= dist && norm(b - p) <= dist;
}
diff --git a/geometry/polygon.cpp b/geometry/polygon.cpp
index 23420a1..1620d7c 100644
--- a/geometry/polygon.cpp
+++ b/geometry/polygon.cpp
@@ -24,7 +24,7 @@ ll windingNumber(pt p, const vector<pt>& poly) {
}
// Testet, ob ein Punkt im Polygon liegt (beliebige Polygone).
-// Ändere Zeile 31 falls rand zählt, poly[0] == poly.back()
+// Ändere Zeile 32 falls rand zählt, poly[0] == poly.back()
bool inside(pt p, const vector<pt>& poly) {
bool in = false;
for (int i = 0; i + 1 < sz(poly); i++) {
@@ -39,7 +39,7 @@ bool inside(pt p, const vector<pt>& poly) {
}
// convex hull without duplicates, h[0] == h.back()
-// Change line 43 and 49 >= if border counts as inside
+// Change line 45 and 51 >= if border counts as inside
bool inside(pt p, const vector<pt>& hull) {
int l = 0, r = sz(hull) - 1;
if (cross(hull[0], hull[r], p) > 0) return false;