LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GeoHalfLine.h
Go to the documentation of this file.
1 
14 #ifndef BASICTOOL_GEOHALFLINE_H
15 #define BASICTOOL_GEOHALFLINE_H
16 
19 
20 #include "TVector3.h"
21 
22 namespace geoalgo {
30  class HalfLine {
31 
32  public:
34  HalfLine();
35 
37  virtual ~HalfLine(){};
38 
40  HalfLine(const double x,
41  const double y,
42  const double z,
43  const double dirx,
44  const double diry,
45  const double dirz);
46 
48  HalfLine(const Point_t& start, const Vector_t& dir);
49 
50  const Point_t& Start() const;
51  const Vector_t& Dir() const;
52 
53  void Start(const double x, const double y, const double z);
54  void Dir(const double x, const double y, const double z);
55 
56  void Start(const TVector3& pt);
57  void Dir(const TVector3& dir);
58 
59  protected:
60  void Normalize();
63 
64  public:
65  //
66  // Template
67  //
68 
70  template <class T, class U>
71  HalfLine(const T& start, const U& dir) : HalfLine(Point_t(start), Vector_t(dir))
72  {}
73 
75  template <class T>
76  void Start(const T& pos)
77  {
78  _start = Point_t(pos);
79  if (_start.size() != 3)
80  throw GeoAlgoException("<<Start>> Only 3 dimensional start point allowed!");
81  }
82 
84  template <class T>
85  void Dir(const T& dir)
86  {
87  _dir = Vector_t(dir);
88  if (_dir.size() != 3)
89  throw GeoAlgoException("<<Start>> Only 3 dimensional start point allowed!");
90  Normalize();
91  }
92  };
93 
95 }
96 #endif
97  // end of doxygen group
Float_t x
Definition: compare.C:6
const Point_t & Start() const
Start getter.
Definition: GeoHalfLine.cxx:28
void Start(const T &pos)
Start setter template.
Definition: GeoHalfLine.h:76
HalfLine HalfLine_t
Definition: GeoHalfLine.h:94
Float_t y
Definition: compare.C:6
Class def header for a class GeoAlgoException.
Double_t z
Definition: plot.C:276
Point_t _start
Beginning of the half line.
Definition: GeoHalfLine.h:61
HalfLine(const T &start, const U &dir)
Alternative ctor using template (3)
Definition: GeoHalfLine.h:71
virtual ~HalfLine()
Default destructor.
Definition: GeoHalfLine.h:37
Class def header for a class Point and Vector.
void Dir(const T &dir)
Dir setter template.
Definition: GeoHalfLine.h:85
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
Vector Point_t
Definition: GeoVector.h:204
HalfLine()
Default constructor.
Definition: GeoHalfLine.cxx:5
Representation of a 3D semi-infinite line. Defines a semi-infinite 3D line by having a start point (P...
Definition: GeoHalfLine.h:30
TDirectory * dir
Definition: macro.C:5
Vector Vector_t
Point has same feature as Vector.
Definition: GeoVector.h:203
Vector_t _dir
Direction of the half line from _start.
Definition: GeoHalfLine.h:62