11 #ifndef DISTANCE_FUNCTIONS_H_ 12 #define DISTANCE_FUNCTIONS_H_ 14 #include <gudhi/Debug_utils.h> 16 #include <gudhi/Miniball.hpp> 18 #include <boost/range/metafunctions.hpp> 19 #include <boost/range/size.hpp> 22 #include <type_traits> 37 template<
typename Po
int >
38 typename std::iterator_traits<typename boost::range_iterator<Point>::type>::value_type
39 operator()(
const Point& p1,
const Point& p2)
const {
40 auto it1 = std::begin(p1);
41 auto it2 = std::begin(p2);
42 typedef typename boost::range_value<Point>::type NT;
44 for (; it1 != std::end(p1); ++it1, ++it2) {
45 GUDHI_CHECK(it2 != std::end(p2),
"inconsistent point dimensions");
49 GUDHI_CHECK(it2 == std::end(p2),
"inconsistent point dimensions");
53 template<
typename T >
54 T operator() (
const std::pair< T, T >& f,
const std::pair< T, T >& s)
const {
55 T dx = f.first - s.first;
56 T dy = f.second - s.second;
58 return sqrt(dx*dx + dy*dy);
75 template<
typename Po
int >
76 typename std::iterator_traits<typename boost::range_iterator<Point>::type>::value_type
77 operator()(
const Point& point_1,
const Point& point_2)
const {
89 template<
typename Point_cloud,
90 typename Point_iterator =
typename boost::range_const_iterator<Point_cloud>::type,
91 typename Point =
typename std::iterator_traits<Point_iterator>::value_type,
92 typename Coordinate_iterator =
typename boost::range_const_iterator<Point>::type,
93 typename Coordinate =
typename std::iterator_traits<Coordinate_iterator>::value_type>
96 using Min_sphere = Miniball::Miniball<Miniball::CoordAccessor<Point_iterator, Coordinate_iterator>>;
98 Min_sphere ms(boost::size(*point_cloud.begin()), point_cloud.begin(), point_cloud.end());
100 std::clog <<
"Minimal_enclosing_ball_radius = " << std::sqrt(ms.squared_radius()) <<
" | nb points = " 101 << boost::size(point_cloud) <<
" | dimension = " 102 << boost::size(*point_cloud.begin()) << std::endl;
103 #endif // DEBUG_TRACES 105 return std::sqrt(ms.squared_radius());
111 #endif // DISTANCE_FUNCTIONS_H_ Compute the Euclidean distance between two Points given by a range of coordinates. The points are assumed to have the same dimension.
Definition: distance_functions.h:34
Definition: SimplicialComplexForAlpha.h:14
Compute the radius of the minimal enclosing ball between Points given by a range of coordinates...
Definition: distance_functions.h:64
Coordinate operator()(const Point_cloud &point_cloud) const
Minimal_enclosing_ball_radius from a point cloud.
Definition: distance_functions.h:95
std::iterator_traits< typename boost::range_iterator< Point >::type >::value_type operator()(const Point &point_1, const Point &point_2) const
Minimal_enclosing_ball_radius from two points.
Definition: distance_functions.h:77