summaryrefslogtreecommitdiff
path: root/src/mbgl/util/geometry_within.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/util/geometry_within.cpp')
-rw-r--r--src/mbgl/util/geometry_within.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mbgl/util/geometry_within.cpp b/src/mbgl/util/geometry_within.cpp
index d6340fc14e..4a0a5cce11 100644
--- a/src/mbgl/util/geometry_within.cpp
+++ b/src/mbgl/util/geometry_within.cpp
@@ -9,7 +9,11 @@ bool rayIntersect(const Point<double>& p, const Point<double>& p1, const Point<d
return ((p1.y > p.y) != (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x);
}
+// check if point p in on line segment with end points p1 and p2
bool onBoundary(const Point<double>& p, const Point<double>& p1, const Point<double>& p2) {
+ // requirements of point p on line segment:
+ // 1. colinear: cross product of vector p->p1(x1, y1) and vector p->p2(x2, y2) equals to 0
+ // 2. p is between p1 and p2
const auto x1 = p.x - p1.x;
const auto y1 = p.y - p1.y;
const auto x2 = p.x - p2.x;