blob: 790f6950567a1aebbfdea633e652b398d866a2b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Hind Montassif
*
* Copyright (C) 2021 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/
#ifndef SPHERE_CIRCUMRADIUS_H_
#define SPHERE_CIRCUMRADIUS_H_
#include <CGAL/Epick_d.h> // for #include <CGAL/NT_converter.h> which is not working/compiling alone
#include <cmath> // for std::sqrt
#include <vector>
namespace Gudhi {
namespace cech_complex {
/** \private @brief Compute the circumradius of the sphere passing through points given by a range of coordinates.
* The points are assumed to have the same dimension. */
template<typename Kernel, typename Filtration_value>
class Sphere_circumradius {
private:
Kernel kernel_;
public:
using FT = typename Kernel::FT;
using Point = typename Kernel::Point_d;
using Point_cloud = typename std::vector<Point>;
CGAL::NT_converter<FT, Filtration_value> cast_to_fv;
/** \brief Circumradius of sphere passing through two points using CGAL.
*
* @param[in] point_1
* @param[in] point_2
* @return Sphere circumradius passing through two points.
* \tparam Point must be a Kernel::Point_d from CGAL.
*
*/
Filtration_value operator()(const Point& point_1, const Point& point_2) const {
return std::sqrt(cast_to_fv(kernel_.squared_distance_d_object()(point_1, point_2))) / 2.;
}
/** \brief Circumradius of sphere passing through point cloud using CGAL.
*
* @param[in] point_cloud The points.
* @return Sphere circumradius passing through the points.
* \tparam Point_cloud must be a range of Kernel::Point_d points from CGAL.
*
*/
Filtration_value operator()(const Point_cloud& point_cloud) const {
return std::sqrt(cast_to_fv(kernel_.compute_squared_radius_d_object()(point_cloud.begin(), point_cloud.end())));
}
};
} // namespace cech_complex
} // namespace Gudhi
#endif // SPHERE_CIRCUMRADIUS_H_
|