All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbncode/sbncode/OpT0Finder/flashmatch/GeoAlgo/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 
17 #include "GeoVector.h"
18 
19 namespace geoalgo {
20  /**
21  \class Spehere
22  @brief Representation of a 3D sphere
23  Defines a 3D Sphere having an center (Point_t) and a radius (double)
24  */
25  class Sphere {
26 
27  public:
28 
29  Sphere(); ///< Default ctor
30  virtual ~Sphere(){} ///< Default dtor
31 
32  /// Alternative ctor (0)
33  Sphere(const double& x, const double& y, const double& z, const double& r);
34 
35  /// Altenartive ctor (1) - 1 Point
36  Sphere(const Point_t& center, const double r=0);
37 
38  /// Alternative ctor (2) - 2 Points
39  Sphere(const Point_t& pt1, const Point_t& pt2);
40 
41  /// Alternative ctor (3) - 3 Points
42  Sphere(const Point_t& A, const Point_t& B, const Point_t& C);
43 
44  // Alternative ctor (4) - 4 Points
45  Sphere(const Point_t& A, const Point_t& B, const Point_t& C, const Point_t& D);
46 
47  // Alternative ctor (5) - Set of points
48  Sphere(const std::vector< ::geoalgo::Point_t>& pts);
49 
50  //
51  // Getters
52  //
53  const Point_t& Center() const; ///< Center getter
54  double Radius() const; ///< Radius getter
55 
56  //
57  // Setters
58  //
59  void Center(const double x, const double y, const double z); ///< Center setter
60  void Center(const Point_t& pt); ///< Center setter
61  void Radius(const double& r); ///< Radius setter
62 
63  //
64  // Utilities
65  //
66  bool Contain(const Point_t& p) const; ///< Judge if a point is contained within a sphere
67 
68  protected:
69 
70  void compat(const Point_t& p, const double r=0) const; ///< 3D point compatibility check
71  void compat(const double& r) const; ///< Positive radius compatibility check
72 
73  /// Center of Sphere
75 
76  /// Radius of Sphere
77  double _radius;
78 
79  public:
80 
81  //
82  // Templates
83  //
84  /*
85 #ifndef __CINT__ // Not sure why but CINT has a problem with this ctor. FIXME
86  template <class T> Sphere(const T& center, const double r=0)
87  : Sphere(Point_t(center),r)
88  {}
89 #endif
90  */
91  template <class T> Sphere(const T& pt1, const T& pt2)
92  : Sphere(Point_t(pt1), Point_t(pt2))
93  {}
94 
95  template <class T> Sphere(const T& A, const T& B, const T& C)
96  : Sphere(Point_t(A), Point_t(B), Point_t(C))
97  {}
98 
99  template <class T> Sphere(const T& A, const T& B, const T& C, const T& D)
100  : Sphere(Point_t(A), Point_t(B), Point_t(C), Point_t(D))
101  {}
102 
103  template <class T> Sphere(const std::vector<T>& pts)
104  {
105  std::vector< ::geoalgo::Vector> geo_pts;
106  geo_pts.reserve(pts);
107  for(auto const& p : pts) geo_pts.emplace_back(p);
108  (*this) = Sphere(geo_pts);
109  }
110 
111  template <class T> void Center(const T& pt)
112  { Center(Point_t(pt)); }
113 
114  template <class T> bool Contain(const T& p) const
115  { return Contain(Point_t(p)); }
116 
117  };
118 
119  typedef Sphere Sphere_t;
120 }
121 #endif
122 /** @} */ // end of doxygen group
123 
bool Contain(const Point_t &p) const
Judge if a point is contained within a sphere.
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
pdgs p
Definition: selectors.fcl:22
process_name opflash particleana ie ie y
Sphere(const T &A, const T &B, const T &C, const T &D)
double Radius() const
Radius getter.
const Point_t & Center() const
Center getter.
void compat(const Point_t &p, const double r=0) const
3D point compatibility check
float A
Definition: dedx.py:137
esac echo uname r