]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add tolerance to BoundingBox::point_inside()
authorNiklas Fehn <fehn@lnm.mw.tum.de>
Thu, 4 Jun 2020 15:52:19 +0000 (17:52 +0200)
committerNiklas Fehn <fehn@lnm.mw.tum.de>
Thu, 4 Jun 2020 15:52:19 +0000 (17:52 +0200)
include/deal.II/base/bounding_box.h
source/base/bounding_box.cc

index 040894ac726e8f2a12bb4b388f41b0f05a6a3636..f97673e26e71fbaeb5e6c02d393ecf4ff8932b5b 100644 (file)
@@ -185,7 +185,9 @@ public:
    * Return true if the point is inside the Bounding Box, false otherwise.
    */
   bool
-  point_inside(const Point<spacedim, Number> &p) const;
+  point_inside(
+    const Point<spacedim, Number> &p,
+    const double tolerance = std::numeric_limits<Number>::epsilon()) const;
 
   /**
    * Increase (or decrease) the size of the bounding box by the given amount.
index 30b3191d456fa03e69cdf90a935196921ccce176..72f097aa073110cd54ba0a364f268970f5ca6026 100644 (file)
@@ -19,19 +19,17 @@ DEAL_II_NAMESPACE_OPEN
 
 template <int spacedim, typename Number>
 bool
-BoundingBox<spacedim, Number>::point_inside(
-  const Point<spacedim, Number> &p) const
+BoundingBox<spacedim, Number>::point_inside(const Point<spacedim, Number> &p,
+                                            const double tolerance) const
 {
   for (unsigned int i = 0; i < spacedim; ++i)
     {
       // Bottom left-top right convention: the point is outside if it's smaller
       // than the first or bigger than the second boundary point The bounding
       // box is defined as a closed set
-      if (std::numeric_limits<Number>::epsilon() *
-              (std::abs(this->boundary_points.first[i] + p[i])) <
+      if (tolerance * std::abs(this->boundary_points.first[i] + p[i]) <
             this->boundary_points.first[i] - p[i] ||
-          std::numeric_limits<Number>::epsilon() *
-              (std::abs(this->boundary_points.second[i] + p[i])) <
+          tolerance * std::abs(this->boundary_points.second[i] + p[i]) <
             p[i] - this->boundary_points.second[i])
         return false;
     }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.