LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GeoHalfLine.cxx
Go to the documentation of this file.
2 
3 namespace geoalgo {
4 
5  HalfLine::HalfLine() : _start(3), _dir(3)
6  {
7  Normalize();
8  }
9 
10  HalfLine::HalfLine(const double x,
11  const double y,
12  const double z,
13  const double dirx,
14  const double diry,
15  const double dirz)
16  : _start(x, y, z), _dir(dirx, diry, dirz)
17  {
18  Normalize();
19  }
20 
21  HalfLine::HalfLine(const Point_t& start, const Vector_t& dir) : _start(start), _dir(dir)
22  {
23  if (start.size() != 3 || dir.size() != 3)
24  throw GeoAlgoException("HalfLine ctor accepts only 3D Point!");
25  Normalize();
26  }
27 
28  const Point_t& HalfLine::Start() const
29  {
30  return _start;
31  }
32 
33  const Vector_t& HalfLine::Dir() const
34  {
35  return _dir;
36  }
37 
38  void HalfLine::Start(const double x, const double y, const double z)
39  {
40  _start[0] = x;
41  _start[1] = y;
42  _start[2] = z;
43  }
44 
45  void HalfLine::Dir(const double x, const double y, const double z)
46  {
47  _dir[0] = x;
48  _dir[1] = y;
49  _dir[2] = z;
50  Normalize();
51  }
52 
53  void HalfLine::Start(const TVector3& pt)
54  {
55  _start[0] = pt[0];
56  _start[1] = pt[1];
57  _start[2] = pt[2];
58  }
59 
60  void HalfLine::Dir(const TVector3& dir)
61  {
62  _dir[0] = dir[0];
63  _dir[1] = dir[1];
64  _dir[2] = dir[2];
65  Normalize();
66  }
67 
69  {
70  auto l = _dir.Length();
71  if (!l) throw GeoAlgoException("<<Normalize>> cannot normalize 0-length direction vector!");
72 
73  // inf check commented out till compatible solution found... --kazu
74  //if(isnan(l))
75  //throw GeoAlgoException("<<Normalize>> cannot normalize inf-length direction vector!");
76  _dir /= l;
77  }
78 }
Float_t x
Definition: compare.C:6
const Point_t & Start() const
Start getter.
Definition: GeoHalfLine.cxx:28
Class def header for a class HalfLine.
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
Point_t _start
Beginning of the half line.
Definition: GeoHalfLine.h:61
double Length() const
Compute the length of the vector.
Definition: GeoVector.cxx:57
TMarker * pt
Definition: egs.C:25
const Vector_t & Dir() const
Direction getter.
Definition: GeoHalfLine.cxx:33
void Normalize()
Normalize direction.
Definition: GeoHalfLine.cxx:68
HalfLine()
Default constructor.
Definition: GeoHalfLine.cxx:5
TDirectory * dir
Definition: macro.C:5
Vector_t _dir
Direction of the half line from _start.
Definition: GeoHalfLine.h:62