diff --git a/GeoLib/Grid.h b/GeoLib/Grid.h index 1438e8be02256fe5a773d6f61f2622fa75e1d8e8..bd07d61b812e375ac9619861b51561c1726d31d2 100644 --- a/GeoLib/Grid.h +++ b/GeoLib/Grid.h @@ -63,7 +63,7 @@ public: for (std::size_t k(0); k < 3; k++) { // make the bounding box a little bit bigger, // such that the node with maximal coordinates fits into the grid - this->_max_pnt[k] *= (1.0 + 1e-6); + this->_max_pnt[k] += std::abs(this->_max_pnt[k]) * 1e-6; if (fabs(this->_max_pnt[k]) < std::numeric_limits<double>::epsilon()) { this->_max_pnt[k] = (this->_max_pnt[k] - this->_min_pnt[k]) * (1.0 + 1e-6); } diff --git a/Tests/GeoLib/TestGrid.cpp b/Tests/GeoLib/TestGrid.cpp index 5db3f31f83b067bb77e447c519accdf78744123e..06c46061da13335aad8dec5ec7b94e5e65a9c9c2 100644 --- a/Tests/GeoLib/TestGrid.cpp +++ b/Tests/GeoLib/TestGrid.cpp @@ -32,6 +32,15 @@ TEST(GeoLib, InsertOnePointInGrid) ASSERT_NO_THROW(GeoLib::Grid<GeoLib::Point> grid(pnts.begin(), pnts.end())); } +TEST(GeoLib, InsertTwoPointsInGrid) +{ + std::vector<GeoLib::Point*> pnts; + pnts.push_back(new GeoLib::Point(4.5, -400.0, 0.0)); + pnts.push_back(new GeoLib::Point(50, -300.0, 0.0)); + ASSERT_NO_THROW(GeoLib::Grid<GeoLib::Point> grid(pnts.begin(), pnts.end())); +} + + TEST(GeoLib, InsertManyPointsInGrid) { const std::size_t i_max(100), j_max(100), k_max(100);