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