summaryrefslogtreecommitdiff
path: root/src/Cech_complex/include/gudhi/sphere_circumradius.h
blob: a6dec3dcf903c7852e9a7cd7ada413a11e91f738 (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
/*    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/Epeck_d.h> // for #include <CGAL/NewKernel_d/KernelD_converter.h>

#include <cmath>  // for std::sqrt
#include <vector>

namespace Gudhi {

namespace cech_complex {

/** @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>
class Sphere_circumradius {
 private:
    Kernel kernel_;
 public:
    using Point = typename Kernel::Point_d;
    using Point_cloud = typename std::vector<Point>;

   /** \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.
   *
   */
  double operator()(const Point& point_1, const Point& point_2) const {
    return std::sqrt(CGAL::to_double(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.
   *
   */
  double operator()(const Point_cloud& point_cloud) const {
    return std::sqrt(CGAL::to_double(kernel_.compute_squared_radius_d_object()(point_cloud.begin(), point_cloud.end())));
  }

};

}  // namespace cech_complex

}  // namespace Gudhi

#endif  // SPHERE_CIRCUMRADIUS_H_