LArSoft  v10_04_05
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(double const x,
41  double const y,
42  double const z,
43  double const dirx,
44  double const diry,
45  double const dirz);
46 
48  HalfLine(Point_t const& start, Vector_t const& dir);
49 
50  Point_t const& Start() const;
51  Vector_t const& Dir() const;
52 
53  void Start(double const x, double const y, double const z);
54  void Dir(double const x, double const y, double const z);
55 
56  void Start(TVector3 const& pt);
57  void Dir(TVector3 const& dir);
58 
59  protected:
60  void Normalize();
63 
64  public:
65  //
66  // Template
67  //
68 
70  template <class T, class U>
71  HalfLine(T const& start, U const& dir) : HalfLine(Point_t(start), Vector_t(dir))
72  {}
73 
75  template <class T>
76  void Start(T const& 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(T const& 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
HalfLine HalfLine_t
Definition: GeoHalfLine.h:94
void Dir(T const &dir)
Dir setter template.
Definition: GeoHalfLine.h:85
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
virtual ~HalfLine()
Default destructor.
Definition: GeoHalfLine.h:37
Class def header for a class Point and Vector.
void Start(T const &pos)
Start setter template.
Definition: GeoHalfLine.h:76
Vector_t const & Dir() const
Direction getter.
Definition: GeoHalfLine.cxx:33
TMarker * pt
Definition: egs.C:25
void Normalize()
Normalize direction.
Definition: GeoHalfLine.cxx:68
Vector Point_t
Definition: GeoVector.h:204
HalfLine()
Default constructor.
Definition: GeoHalfLine.cxx:5
HalfLine(T const &start, U const &dir)
Alternative ctor using template (3)
Definition: GeoHalfLine.h:71
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
Point_t const & Start() const
Start getter.
Definition: GeoHalfLine.cxx:28
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