From 9de351a90b85d19538ae10bfd79333dcb120867c Mon Sep 17 00:00:00 2001 From: "Dmitry Yu. Naumov" <github@naumov.de> Date: Sat, 18 Jul 2015 22:17:59 +0000 Subject: [PATCH] [MaL] Remove op<=(Point3d, ..). The operator is unused. There is a replacement named LessEq(), which is also taking an epsilon into account and is used. The operator is not consistent with the operator<() for Point3d, because of the epsilon. --- MathLib/Point3d.cpp | 27 -------------- MathLib/Point3d.h | 5 --- Tests/MathLib/TestPoint3d.cpp | 66 ----------------------------------- 3 files changed, 98 deletions(-) diff --git a/MathLib/Point3d.cpp b/MathLib/Point3d.cpp index d0e3b8c3a8b..71277056070 100644 --- a/MathLib/Point3d.cpp +++ b/MathLib/Point3d.cpp @@ -48,33 +48,6 @@ bool operator< (const MathLib::Point3d& p0, const MathLib::Point3d& p1) } } -bool operator<= (const MathLib::Point3d& p0, const MathLib::Point3d& p1) -{ - if (p0[0] > p1[0]) { - return false; - } else { - if (p0[0] < p1[0]) { - return true; - } - } - // => p0[0] == p1[0] - - if (p0[1] > p1[1]) { - return false; - } else { - if (p0[1] < p1[1]) { - return true; - } - } - // => p0[1] == p1[1] - - if (p0[2] > p1[2]) { - return false; - } else { - return true; - } -} - bool lessEq(const MathLib::Point3d& p0, const MathLib::Point3d& p1, double tol) { // test a relative and an absolute criterion diff --git a/MathLib/Point3d.h b/MathLib/Point3d.h index 93aae8d66f5..0c8c985e58b 100644 --- a/MathLib/Point3d.h +++ b/MathLib/Point3d.h @@ -25,11 +25,6 @@ typedef MathLib::TemplatePoint<double,3> Point3d; bool operator< (MathLib::Point3d const & p0, MathLib::Point3d const & p1); -/** - * lexicographic comparison of points - */ -bool operator<= (MathLib::Point3d const & p0, MathLib::Point3d const & p1); - /** * lexicographical comparison of points taking an epsilon into account * @param p0 first input Point3d diff --git a/Tests/MathLib/TestPoint3d.cpp b/Tests/MathLib/TestPoint3d.cpp index fd67e02402b..b5e4618ceed 100644 --- a/Tests/MathLib/TestPoint3d.cpp +++ b/Tests/MathLib/TestPoint3d.cpp @@ -102,72 +102,6 @@ TEST(MathLib, Point3dComparisonLessEq) ASSERT_TRUE(lessEq(Point3d(std::array<double,3>({{10.0,10.0,10.0}})),Point3d(std::array<double,3>({{10.0,10.0,10.0+half_eps}})))); } -TEST(MathLib, Point3dComparisonOperatorLessEq) -{ - const double my_eps(std::numeric_limits<double>::epsilon()); - ASSERT_FALSE(Point3d(std::array<double,3>({{1.0+my_eps,1.0,1.0}})) <= - Point3d(std::array<double,3>({{1.0,1.0,1.0}}))); - ASSERT_FALSE(Point3d(std::array<double,3>({{1.0,1.0+my_eps,1.0}})) <= - Point3d(std::array<double,3>({{1.0,1.0,1.0}}))); - ASSERT_FALSE(Point3d(std::array<double,3>({{1.0,1.0,1.0+my_eps}})) <= - Point3d(std::array<double,3>({{1.0,1.0,1.0}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{1.0,1.0,1.0}})) <= - Point3d(std::array<double,3>({{1.0+my_eps,1.0,1.0}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{1.0,1.0,1.0}})) <= - Point3d(std::array<double,3>({{1.0,1.0+my_eps,1.0}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{1.0,1.0,1.0}})) <= - Point3d(std::array<double,3>({{1.0,1.0,1.0+my_eps}}))); - - ASSERT_TRUE(Point3d(std::array<double,3>({{1.0-my_eps,1.0,1.0}})) <= - Point3d(std::array<double,3>({{1.0,1.0,1.0}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{1.0,1.0-my_eps,1.0}})) <= - Point3d(std::array<double,3>({{1.0,1.0,1.0}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{1.0,1.0,1.0-my_eps}})) <= - Point3d(std::array<double,3>({{1.0,1.0,1.0}}))); - ASSERT_FALSE(Point3d(std::array<double,3>({{1.0,1.0,1.0}})) <= - Point3d(std::array<double,3>({{1.0-my_eps,1.0,1.0}}))); - ASSERT_FALSE(Point3d(std::array<double,3>({{1.0,1.0,1.0}})) <= - Point3d(std::array<double,3>({{1.0,1.0-my_eps,1.0}}))); - ASSERT_FALSE(Point3d(std::array<double,3>({{1.0,1.0,1.0}})) <= - Point3d(std::array<double,3>({{1.0,1.0,1.0-my_eps}}))); - - std::size_t n(10000); - srand ( static_cast<unsigned>(time(NULL)) ); - for (std::size_t k(0); k<n; ++k) { - double random_val_x(((double)(rand()) / RAND_MAX - 0.5)); //real_dist(rng)); - double random_val_y(((double)(rand()) / RAND_MAX - 0.5)); //real_dist(rng)); - double random_val_z(((double)(rand()) / RAND_MAX - 0.5)); //real_dist(rng)); - - double big_x(random_val_x * std::numeric_limits<double>::max()); - double big_y(random_val_y * std::numeric_limits<double>::max()); - double big_z(random_val_z * std::numeric_limits<double>::max()); - - ASSERT_TRUE(Point3d(std::array<double,3>({{big_x-my_eps,big_y,big_z}})) <= Point3d(std::array<double,3>({{big_x,big_y,big_z}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{big_x,big_y-my_eps,big_z}})) <= Point3d(std::array<double,3>({{big_x,big_y,big_z}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{big_x,big_y,big_z-my_eps}})) <= Point3d(std::array<double,3>({{big_x,big_y,big_z}}))); - - ASSERT_TRUE(Point3d(std::array<double,3>({{big_x-my_eps,big_y-my_eps,big_z}})) <= Point3d(std::array<double,3>({{big_x,big_y,big_z}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{big_x-my_eps,big_y,big_z-my_eps}})) <= Point3d(std::array<double,3>({{big_x,big_y,big_z}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{big_x,big_y-my_eps,big_z-my_eps}})) <= Point3d(std::array<double,3>({{big_x,big_y,big_z}}))); - - ASSERT_TRUE(Point3d(std::array<double,3>({{big_x-my_eps,big_y-my_eps,big_z-my_eps}})) <= Point3d(std::array<double,3>({{big_x,big_y,big_z}}))); - - double small_x(random_val_x * std::numeric_limits<double>::epsilon()); - double small_y(random_val_y * std::numeric_limits<double>::epsilon()); - double small_z(random_val_z * std::numeric_limits<double>::epsilon()); - - ASSERT_TRUE(Point3d(std::array<double,3>({{small_x-my_eps,small_y,small_z}})) <= Point3d(std::array<double,3>({{small_x,small_y,small_z}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{small_x,small_y-my_eps,small_z}})) <= Point3d(std::array<double,3>({{small_x,small_y,small_z}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{small_x,small_y,small_z-my_eps}})) <= Point3d(std::array<double,3>({{small_x,small_y,small_z}}))); - - ASSERT_TRUE(Point3d(std::array<double,3>({{small_x-my_eps,small_y-my_eps,small_z}})) <= Point3d(std::array<double,3>({{small_x,small_y,small_z}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{small_x-my_eps,small_y,small_z-my_eps}})) <= Point3d(std::array<double,3>({{small_x,small_y,small_z}}))); - ASSERT_TRUE(Point3d(std::array<double,3>({{small_x,small_y-my_eps,small_z-my_eps}})) <= Point3d(std::array<double,3>({{small_x,small_y,small_z}}))); - - ASSERT_TRUE(Point3d(std::array<double,3>({{small_x-my_eps,small_y-my_eps,small_z-my_eps}})) <= Point3d(std::array<double,3>({{small_x,small_y,small_z}}))); - } -} - // test for operator== TEST(MathLib, Point3dComparisonOperatorEqual) { -- GitLab