GeoHalfLine.cxx
Go to the documentation of this file.
2 
3 namespace geoalgo {
4 
6  : _start(3)
7  , _dir(3)
8  {Normalize();}
9 
10  HalfLine::HalfLine(const double x, const double y, const double z,
11  const double dirx, const double diry, const double dirz)
12  : _start (x, y, z )
13  , _dir (dirx, diry, dirz)
14  {Normalize();}
15 
16  HalfLine::HalfLine(const Point_t& start, const Vector_t& dir)
17  : _start ( start )
18  , _dir ( dir )
19  {
20  if(start.size()!=3 || dir.size()!=3)
21  throw GeoAlgoException("HalfLine ctor accepts only 3D Point!");
22  Normalize();
23  }
24 
25  const Point_t& HalfLine::Start() const { return _start; }
26 
27  const Vector_t& HalfLine::Dir() const { return _dir; }
28 
29  void HalfLine::Start(const double x, const double y, const double z)
30  { _start[0] = x; _start[1] = y; _start[2] = z; }
31 
32  void HalfLine::Dir(const double x, const double y, const double z)
33  { _dir[0] = x; _dir[1] = y; _dir[2] = z; Normalize(); }
34 
35  void HalfLine::Start(const TVector3& pt)
36  { _start[0] = pt[0]; _start[1] = pt[1]; _start[2] = pt[2]; }
37 
38  void HalfLine::Dir(const TVector3& dir)
39  { _dir[0] = dir[0]; _dir[1] = dir[1]; _dir[2] = dir[2]; Normalize(); }
40 
42  {
43  auto l = _dir.Length();
44  if(!l)
45  throw GeoAlgoException("<<Normalize>> cannot normalize 0-length direction vector!");
46 
47  // inf check commented out till compatible solution found... --kazu
48  //if(isnan(l))
49  //throw GeoAlgoException("<<Normalize>> cannot normalize inf-length direction vector!");
50  _dir /= l;
51  }
52 }
const Point_t & Start() const
Start getter.
Definition: GeoHalfLine.cxx:25
Class def header for a class HalfLine.
Point_t _start
Beginning of the half line.
Definition: GeoHalfLine.h:59
string dir
static QStrList * l
Definition: config.cpp:1044
double Length() const
Compute the length of the vector.
Definition: GeoVector.cxx:40
const Vector_t & Dir() const
Direction getter.
Definition: GeoHalfLine.cxx:27
void Normalize()
Normalize direction.
Definition: GeoHalfLine.cxx:41
HalfLine()
Default constructor.
Definition: GeoHalfLine.cxx:5
list x
Definition: train.py:276
Vector_t _dir
Direction of the half line from _start.
Definition: GeoHalfLine.h:60