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