diff options
author | vng <viktor.govako@gmail.com> | 2015-12-23 19:33:05 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:03:17 +0300 |
commit | f6ac3786d755afde9534b28e9a1977e38b3aa470 (patch) | |
tree | 239acb986e517ef84c31d4991a37df7f6d3bc4c1 /geometry/geometry_tests/robust_test.cpp | |
parent | 8c57791e1d87fa500b3f7bb1b13f45282edc0cf1 (diff) |
Refactored some geometry functions.
Correct implementation of feature::GetMinDistanceMeters().
Diffstat (limited to 'geometry/geometry_tests/robust_test.cpp')
-rw-r--r-- | geometry/geometry_tests/robust_test.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/geometry/geometry_tests/robust_test.cpp b/geometry/geometry_tests/robust_test.cpp index 04e5f356c2..0eb3d79091 100644 --- a/geometry/geometry_tests/robust_test.cpp +++ b/geometry/geometry_tests/robust_test.cpp @@ -1,20 +1,47 @@ #include "testing/testing.hpp" #include "geometry/robust_orientation.hpp" +#include "geometry/triangle2d.hpp" -typedef m2::PointD P; +using namespace m2::robust; namespace { + typedef m2::PointD P; + template <typename IterT> void CheckSelfIntersections(IterT beg, IterT end, bool res) { - TEST_EQUAL(m2::robust::CheckPolygonSelfIntersections(beg, end), res, ()); + TEST_EQUAL(CheckPolygonSelfIntersections(beg, end), res, ()); typedef std::reverse_iterator<IterT> ReverseIterT; - TEST_EQUAL(m2::robust::CheckPolygonSelfIntersections(ReverseIterT(end), ReverseIterT(beg)), res, ()); + TEST_EQUAL(CheckPolygonSelfIntersections(ReverseIterT(end), ReverseIterT(beg)), res, ()); } } +UNIT_TEST(OrientedS_Smoke) +{ + m2::PointD arr[] = {{-1, -1}, {0, 0}, {1, -1}}; + TEST(OrientedS(arr[0], arr[2], arr[1]) > 0, ()); + TEST(OrientedS(arr[2], arr[0], arr[1]) < 0, ()); +} + +UNIT_TEST(Triangle_Smoke) +{ + m2::PointD arr[] = {{0, 0}, {0, 3}, {3, 0}}; + + TEST(IsPointInsideTriangle(arr[0], arr[0], arr[1], arr[2]), ()); + TEST(IsPointInsideTriangle(arr[1], arr[0], arr[1], arr[2]), ()); + TEST(IsPointInsideTriangle(arr[2], arr[0], arr[1], arr[2]), ()); + TEST(IsPointInsideTriangle({1, 1}, arr[0], arr[1], arr[2]), ()); + TEST(IsPointInsideTriangle({1, 2}, arr[0], arr[1], arr[2]), ()); + TEST(IsPointInsideTriangle({2, 1}, arr[0], arr[1], arr[2]), ()); + + double constexpr eps = 1.0E-10; + TEST(!IsPointInsideTriangle({-eps, -eps}, arr[0], arr[1], arr[2]), ()); + TEST(!IsPointInsideTriangle({1 + eps, 2}, arr[0], arr[1], arr[2]), ()); + TEST(!IsPointInsideTriangle({2, 1 + eps}, arr[0], arr[1], arr[2]), ()); +} + UNIT_TEST(PolygonSelfIntersections_IntersectSmoke) { { |