LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
GeoCylinder.cxx
Go to the documentation of this file.
1 #ifndef BASICTOOL_GEOCYLINDER_CXX
2 #define BASICTOOL_GEOCYLINDER_CXX
3 
4 #include "GeoCylinder.h"
5 
6 namespace geoalgo {
7 
9  : Line()
10  , _radius (0.)
11  {}
12 
13  Cylinder::Cylinder(const double x_min, const double y_min, const double z_min,
14  const double x_max, const double y_max, const double z_max,
15  const double radius)
16  : Line(x_min, y_min, z_min, x_max, y_max, z_max)
17  , _radius ( radius )
18  {}
19 
20  Cylinder::Cylinder(const Point_t& min, const Vector_t& max, const double radius)
21  : Line(min, max)
22  , _radius ( radius )
23  {
24  if(min.size()!=3 || max.size()!=3)
25  throw GeoAlgoException("Cylinder ctor accepts only 3D Point!");
26  }
27 
28  bool Cylinder::Contain(const Point_t &pt) const {
29 
30  // get a vector that defines the axis of the cylinder
31  Vector_t axis = _pt1-_pt2;
32  Vector_t dirpt = pt-_pt2;
33 
34  // angle of point w.r.t. the axis
35  double angleMin = axis.Angle(dirpt);
36 
37  // if the angle is > 90 -> outside -> return
38  if (angleMin > 0.5*3.14)
39  return false;
40 
41  // revert the axis direction
42  axis = _pt2-_pt1;
43  dirpt = pt-_pt1;
44  angleMin = axis.Angle(dirpt);
45 
46  // if the angle is > 90 -> outside -> return
47  if (angleMin > 0.5*3.14)
48  return false;
49 
50  // if still here, all that is left to verify is
51  // that the point isn't more than a radius
52  // away from the cylinder axis
53  // 1) make a line corresponding to the axis
54  // 2) get the distance between the point and the line
55  double radial_dist_sq = _geoAlgo.SqDist(*this,pt);
56 
57  if (radial_dist_sq > _radius*_radius)
58  return false;
59 
60  return true;
61 
62  }
63 }
64 #endif
65 
66 
double SqDist(const Line_t &line, const Point_t &pt) const
Definition: GeoAlgo.h:92
Point_t _pt1
First point denoting infinite line.
Definition: GeoLine.h:61
double x_min
Definition: berger.C:15
double _radius
Radius of the cylinder.
Definition: GeoCylinder.h:58
Int_t max
Definition: plot.C:27
TMarker * pt
Definition: egs.C:25
Cylinder()
Default constructor.
Definition: GeoCylinder.cxx:8
Representation of a 3D infinite line. Defines an infinite 3D line by having 2 points which completely...
Definition: GeoLine.h:27
Double_t radius
double x_max
Definition: berger.C:16
bool Contain(const Point_t &pt) const
Containment evaluation.
Definition: GeoCylinder.cxx:28
Int_t min
Definition: plot.C:26
Vector_t _pt2
Second point denoting infinite line.
Definition: GeoLine.h:62
Class def header for a class Cylinder.
double Angle(const Vector &obj) const
Compute a cross product of two vectors.
Definition: GeoVector.cxx:80