GeoSphere.h
Go to the documentation of this file.
1 /**
2  * \file GeoSphere.h
3  *
4  * \ingroup GeoAlgo
5  *
6  * \brief Class def header for a class HalfLine
7  *
8  * @author kazuhiro
9  */
10 
11 /** \addtogroup GeoAlgo
12 
13  @{*/
14 #ifndef BASICTOOL_GEOSPHERE_H
15 #define BASICTOOL_GEOSPHERE_H
16 
18 
19 #include <vector>
20 
21 namespace geoalgo {
22  /**
23  \class Spehere
24  @brief Representation of a 3D sphere
25  Defines a 3D Sphere having an center (Point_t) and a radius (double)
26  */
27  class Sphere {
28 
29  public:
30 
31  Sphere(); ///< Default ctor
32  virtual ~Sphere(){} ///< Default dtor
33 
34  /// Alternative ctor (0)
35  Sphere(const double& x, const double& y, const double& z, const double& r);
36 
37  /// Altenartive ctor (1) - 1 Point
38  Sphere(const Point_t& center, const double r=0);
39 
40  /// Alternative ctor (2) - 2 Points
41  Sphere(const Point_t& pt1, const Point_t& pt2);
42 
43  /// Alternative ctor (3) - 3 Points
44  Sphere(const Point_t& A, const Point_t& B, const Point_t& C);
45 
46  // Alternative ctor (4) - 4 Points
47  Sphere(const Point_t& A, const Point_t& B, const Point_t& C, const Point_t& D);
48 
49  // Alternative ctor (5) - Set of points
50  Sphere(const std::vector< ::geoalgo::Point_t>& pts);
51 
52  //
53  // Getters
54  //
55  const Point_t& Center() const; ///< Center getter
56  double Radius() const; ///< Radius getter
57 
58  //
59  // Setters
60  //
61  void Center(const double x, const double y, const double z); ///< Center setter
62  void Center(const Point_t& pt); ///< Center setter
63  void Radius(const double& r); ///< Radius setter
64 
65  //
66  // Utilities
67  //
68  bool Contain(const Point_t& p) const; ///< Judge if a point is contained within a sphere
69 
70  protected:
71 
72  void compat(const Point_t& p, const double r=0) const; ///< 3D point compatibility check
73  void compat(const double& r) const; ///< Positive radius compatibility check
74 
75  /// Center of Sphere
77 
78  /// Radius of Sphere
79  double _radius;
80 
81  public:
82 
83  //
84  // Templates
85  //
86  /*
87 #ifndef __CINT__ // Not sure why but CINT has a problem with this ctor. FIXME
88  template <class T> Sphere(const T& center, const double r=0)
89  : Sphere(Point_t(center),r)
90  {}
91 #endif
92  */
93  template <class T> Sphere(const T& pt1, const T& pt2)
94  : Sphere(Point_t(pt1), Point_t(pt2))
95  {}
96 
97  template <class T> Sphere(const T& A, const T& B, const T& C)
98  : Sphere(Point_t(A), Point_t(B), Point_t(C))
99  {}
100 
101  template <class T> Sphere(const T& A, const T& B, const T& C, const T& D)
102  : Sphere(Point_t(A), Point_t(B), Point_t(C), Point_t(D))
103  {}
104 
105  template <class T> Sphere(const std::vector<T>& pts)
106  {
107  std::vector< ::geoalgo::Vector> geo_pts;
108  geo_pts.reserve(pts);
109  for(auto const& p : pts) geo_pts.emplace_back(p);
110  (*this) = Sphere(geo_pts);
111  }
112 
113  template <class T> void Center(const T& pt)
114  { Center(Point_t(pt)); }
115 
116  template <class T> bool Contain(const T& p) const
117  { return Contain(Point_t(p)); }
118 
119  };
120 
121  typedef Sphere Sphere_t;
122 }
123 #endif
124 /** @} */ // end of doxygen group
bool Contain(const Point_t &p) const
Judge if a point is contained within a sphere.
Definition: GeoSphere.cxx:357
Sphere(const T &pt1, const T &pt2)
Definition: GeoSphere.h:93
virtual ~Sphere()
Default dtor.
Definition: GeoSphere.h:32
bool Contain(const T &p) const
Definition: GeoSphere.h:116
void Center(const T &pt)
Definition: GeoSphere.h:113
Sphere(const T &A, const T &B, const T &C)
Definition: GeoSphere.h:97
Sphere(const T &A, const T &B, const T &C, const T &D)
Definition: GeoSphere.h:101
Class def header for a class Point and Vector.
p
Definition: test.py:223
double Radius() const
Radius getter.
Definition: GeoSphere.cxx:346
const Point_t & Center() const
Center getter.
Definition: GeoSphere.cxx:344
Sphere(const std::vector< T > &pts)
Definition: GeoSphere.h:105
Vector Point_t
Definition: GeoVector.h:196
Point_t _center
Center of Sphere.
Definition: GeoSphere.h:76
def center(depos, point)
Definition: depos.py:117
void compat(const Point_t &p, const double r=0) const
3D point compatibility check
Definition: GeoSphere.cxx:363
double _radius
Radius of Sphere.
Definition: GeoSphere.h:79
list x
Definition: train.py:276
Sphere Sphere_t
Definition: GeoSphere.h:121
Sphere()
Default ctor.
Definition: GeoSphere.cxx:8