All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbncode/sbncode/OpT0Finder/flashmatch/GeoAlgo/GeoHalfLine.h
Go to the documentation of this file.
1 /**
2  * \file GeoHalfLine.h
3  *
4  * \ingroup GeoAlgo
5  *
6  * \brief Class def header for a class HalfLine
7  *
8  * @author kazuhiro
9  */
10 
11 /** \addtogroup GeoAlgo
12 
13  @{*/
14 #ifndef BASICTOOL_GEOHALFLINE_H
15 #define BASICTOOL_GEOHALFLINE_H
16 
17 #include "GeoVector.h"
18 namespace geoalgo {
19  /**
20  \class HalfLine
21  @brief Representation of a 3D semi-infinite line.
22  Defines a semi-infinite 3D line by having a start point (Point_t) and direction (Vector_t) \n
23  along which the line extends. It hides the start and direction attributes from users for \n
24  protecting the dimensionality.
25  */
26  class HalfLine {
27 
28  public:
29 
30  /// Default constructor
31  HalfLine();
32 
33  /// Default destructor
34  virtual ~HalfLine(){};
35 
36  /// Alternative ctor (1)
37  HalfLine(const double x, const double y, const double z,
38  const double dirx, const double diry, const double dirz);
39 
40  /// Altenartive ctor (2)
41  HalfLine(const Point_t& start, const Vector_t& dir);
42 
43  const Point_t& Start () const; ///< Start getter
44  const Vector_t& Dir () const; ///< Direction getter
45 
46  void Start(const double x, const double y, const double z); ///< Start setter
47  void Dir (const double x, const double y, const double z); ///< Dir setter
48 
49  void Start(const TVector3& pt ); ///< Start setter
50  void Dir (const TVector3& dir); ///< Dir setter
51 
52  protected:
53 
54  void Normalize(); ///< Normalize direction
55  Point_t _start; ///< Beginning of the half line
56  Vector_t _dir; ///< Direction of the half line from _start
57 
58  public:
59 
60  //
61  // Template
62  //
63 
64  /// Alternative ctor using template (3)
65  template <class T, class U> HalfLine(const T& start, const U& dir)
66  : HalfLine(Point_t(start), Vector_t(dir))
67  {}
68 
69  /// Start setter template
70  template<class T>
71  void Start(const T& pos)
72  {
73  _start = Point_t(pos);
74  if(_start.size()!=3) throw GeoAlgoException("<<Start>> Only 3 dimensional start point allowed!");
75  }
76 
77  /// Dir setter template
78  template<class T>
79  void Dir(const T& dir)
80  {
81  _dir = Vector_t(dir);
82  if(_dir.size()!=3) throw GeoAlgoException("<<Start>> Only 3 dimensional start point allowed!");
83  Normalize();
84  }
85 
86  };
87 
88  typedef HalfLine HalfLine_t;
89 }
90 #endif
91 /** @} */ // end of doxygen group
92 
process_name opflash particleana ie ie ie z
const Point_t & Start() const
Start getter.
void Start(const T &pos)
Start setter template.
process_name opflash particleana ie x
Point_t _start
Beginning of the half line.
HalfLine(const T &start, const U &dir)
Alternative ctor using template (3)
process_name opflash particleana ie ie y
const Vector_t & Dir() const
Direction getter.
tuple dir
Definition: dropbox.py:28
Representation of a 3D semi-infinite line. Defines a semi-infinite 3D line by having a start point (P...
Vector Vector_t
Point has same feature as Vector.
Vector_t _dir
Direction of the half line from _start.