Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarafei Praliaskouski <komzpa@gmail.com>2013-05-11 20:34:50 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:54:45 +0300
commit559946f2fcb276741ccc8e9196a8ce877d9f4d21 (patch)
treee6eb3b97f7faebbf775d69586e28e2874556eb9e /geometry
parent4c85637c9eab296d879d7b31344b920eb81f48f6 (diff)
[geometry] add IsPointInsideTriangle implementation
Diffstat (limited to 'geometry')
-rw-r--r--geometry/point2d.hpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/geometry/point2d.hpp b/geometry/point2d.hpp
index 5eac29a852..fe00af121f 100644
--- a/geometry/point2d.hpp
+++ b/geometry/point2d.hpp
@@ -200,6 +200,16 @@ namespace m2
}
template <typename T>
+ bool IsPointInsideTriangle(Point<T> const & p,
+ Point<T> const & a, Point<T> const & b, Point<T> const & c)
+ {
+ T const cpab = CrossProduct(b - a, p - a);
+ T const cpbc = CrossProduct(c - b, p - b);
+ T const cpca = CrossProduct(a - c, p - c);
+ return (cpab <= 0 && cpbc <= 0 && cpca <= 0) || (cpab >= 0 && cpbc >= 0 && cpca >= 0);
+ }
+
+ template <typename T>
bool IsPointStrictlyInsideTriangle(Point<T> const & p,
Point<T> const & a, Point<T> const & b, Point<T> const & c)
{