All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbncode/sbncode/OpT0Finder/flashmatch/GeoAlgo/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 
43  void HalfLine::Normalize()
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 
process_name opflash particleana ie ie ie z
const Point_t & Start() const
Start getter.
process_name opflash particleana ie x
Point_t _start
Beginning of the half line.
recob::tracking::Point_t Point_t
double Length() const
Compute the length of the vector.
process_name opflash particleana ie ie y
const Vector_t & Dir() const
Direction getter.
tuple dir
Definition: dropbox.py:28
recob::tracking::Vector_t Vector_t
Vector_t _dir
Direction of the half line from _start.