LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
GeoSphere.h
Go to the documentation of this file.
1 
14 #ifndef BASICTOOL_GEOSPHERE_H
15 #define BASICTOOL_GEOSPHERE_H
16 
17 #include "GeoVector.h"
18 
19 namespace geoalgo {
25  class Sphere {
26 
27  public:
28 
29  Sphere();
30  virtual ~Sphere(){}
31 
33  Sphere(const double& x, const double& y, const double& z, const double& r);
34 
36  Sphere(const Point_t& center, const double r=0);
37 
39  Sphere(const Point_t& pt1, const Point_t& pt2);
40 
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;
54  double Radius() const;
55 
56  //
57  // Setters
58  //
59  void Center(const double x, const double y, const double z);
60  void Center(const Point_t& pt);
61  void Radius(const double& r);
62 
63  //
64  // Utilities
65  //
66  bool Contain(const Point_t& p) const;
67 
68  protected:
69 
70  void compat(const Point_t& p, const double r=0) const;
71  void compat(const double& r) const;
72 
75 
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 
Float_t x
Definition: compare.C:6
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:91
virtual ~Sphere()
Default dtor.
Definition: GeoSphere.h:30
bool Contain(const T &p) const
Definition: GeoSphere.h:114
Float_t y
Definition: compare.C:6
Int_t B
Definition: plot.C:25
Double_t z
Definition: plot.C:279
void Center(const T &pt)
Definition: GeoSphere.h:111
Sphere(const T &A, const T &B, const T &C)
Definition: GeoSphere.h:95
Sphere(const T &A, const T &B, const T &C, const T &D)
Definition: GeoSphere.h:99
Class def header for a class Point and Vector.
TMarker * pt
Definition: egs.C:25
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:103
Vector Point_t
Definition: GeoVector.h:200
Point_t _center
Center of Sphere.
Definition: GeoSphere.h:74
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:77
Sphere Sphere_t
Definition: GeoSphere.h:119
Sphere()
Default ctor.
Definition: GeoSphere.cxx:8