[extensions][nsphere][within][strategies] For NSphere/Box and Point/Nsphere take into account machine epsilon.

This commit is contained in:
Adam Wulkiewicz
2015-08-05 00:59:44 +02:00
parent 9d4c806994
commit 3a522f11f6
3 changed files with 28 additions and 21 deletions

View File

@@ -1,9 +1,9 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -28,6 +28,8 @@
#include <boost/geometry/extensions/nsphere/core/tags.hpp>
#include <boost/geometry/extensions/nsphere/algorithms/assign.hpp>
#include <boost/geometry/util/math.hpp>
namespace boost { namespace geometry
{
@@ -66,7 +68,7 @@ inline bool point_in_circle(P const& p, C const& c)
strategy_type, P, point_type
>::apply(strategy, get_radius<0>(c));
return r < rad;
return math::smaller(r, rad);
}
/// 2D version
template<typename T, typename C>

View File

@@ -1,9 +1,9 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, London, UK.
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2015 Adam Wulkiewicz, London, UK.
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -20,6 +20,7 @@
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/strategies/covered_by.hpp>
#include <boost/geometry/strategies/within.hpp>
#include <boost/geometry/util/math.hpp>
namespace boost { namespace geometry { namespace strategy
@@ -36,7 +37,8 @@ struct nsphere_within_range
, ContainingValue const& ing_min
, ContainingValue const& ing_max)
{
return ing_min < ed_min && ed_max < ing_max;
return math::smaller(ing_min, ed_min)
&& math::smaller(ed_max, ing_max);
}
};
@@ -49,7 +51,8 @@ struct nsphere_covered_by_range
, ContainingValue const& ing_min
, ContainingValue const& ing_max)
{
return ing_min <= ed_min && ed_max <= ing_max;
return math::smaller_or_equals(ing_min, ed_min)
&& math::smaller_or_equals(ed_max, ing_max);
}
};

View File

@@ -1,9 +1,9 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, London, UK.
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2015 Adam Wulkiewicz, London, UK.
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -23,6 +23,8 @@
#include <boost/geometry/extensions/nsphere/views/center_view.hpp>
#include <boost/geometry/util/math.hpp>
namespace boost { namespace geometry { namespace strategy
{
@@ -32,10 +34,10 @@ namespace within
struct point_nsphere_within_comparable_distance
{
template <typename ComparableDistance, typename Radius>
static inline bool apply(ComparableDistance const& ed_comp_dist
, Radius const& ing_radius)
static inline bool apply(ComparableDistance const& ed_comp_dist,
Radius const& ing_radius)
{
return ed_comp_dist < ing_radius * ing_radius;
return math::smaller(ed_comp_dist, ing_radius * ing_radius);
}
};
@@ -43,10 +45,10 @@ struct point_nsphere_within_comparable_distance
struct point_nsphere_covered_by_comparable_distance
{
template <typename ComparableDistance, typename Radius>
static inline bool apply(ComparableDistance const& ed_comp_dist
, Radius const& ing_radius)
static inline bool apply(ComparableDistance const& ed_comp_dist,
Radius const& ing_radius)
{
return ed_comp_dist <= ing_radius * ing_radius;
return math::smaller_or_equals(ed_comp_dist, ing_radius * ing_radius);
}
};