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 
19 
20 #include "TVector3.h"
21 
22 namespace geoalgo {
23  /**
24  \class HalfLine
25  @brief Representation of a 3D semi-infinite line.
26  Defines a semi-infinite 3D line by having a start point (Point_t) and direction (Vector_t) \n
27  along which the line extends. It hides the start and direction attributes from users for \n
28  protecting the dimensionality.
29  */
30  class HalfLine {
31 
32  public:
33 
34  /// Default constructor
35  HalfLine();
36 
37  /// Default destructor
38  virtual ~HalfLine(){};
39 
40  /// Alternative ctor (1)
41  HalfLine(const double x, const double y, const double z,
42  const double dirx, const double diry, const double dirz);
43 
44  /// Altenartive ctor (2)
45  HalfLine(const Point_t& start, const Vector_t& dir);
46 
47  const Point_t& Start () const; ///< Start getter
48  const Vector_t& Dir () const; ///< Direction getter
49 
50  void Start(const double x, const double y, const double z); ///< Start setter
51  void Dir (const double x, const double y, const double z); ///< Dir setter
52 
53  void Start(const TVector3& pt ); ///< Start setter
54  void Dir (const TVector3& dir); ///< Dir setter
55 
56  protected:
57 
58  void Normalize(); ///< Normalize direction
59  Point_t _start; ///< Beginning of the half line
60  Vector_t _dir; ///< Direction of the half line from _start
61 
62  public:
63 
64  //
65  // Template
66  //
67 
68  /// Alternative ctor using template (3)
69  template <class T, class U> HalfLine(const T& start, const U& dir)
70  : HalfLine(Point_t(start), Vector_t(dir))
71  {}
72 
73  /// Start setter template
74  template<class T>
75  void Start(const T& pos)
76  {
77  _start = Point_t(pos);
78  if(_start.size()!=3) throw GeoAlgoException("<<Start>> Only 3 dimensional start point allowed!");
79  }
80 
81  /// Dir setter template
82  template<class T>
83  void Dir(const T& dir)
84  {
85  _dir = Vector_t(dir);
86  if(_dir.size()!=3) throw GeoAlgoException("<<Start>> Only 3 dimensional start point allowed!");
87  Normalize();
88  }
89 
90  };
91 
93 }
94 #endif
95 /** @} */ // end of doxygen group
const Point_t & Start() const
Start getter.
Definition: GeoHalfLine.cxx:25
void Start(const T &pos)
Start setter template.
Definition: GeoHalfLine.h:75
HalfLine HalfLine_t
Definition: GeoHalfLine.h:92
Class def header for a class GeoAlgoException.
Point_t _start
Beginning of the half line.
Definition: GeoHalfLine.h:59
string dir
HalfLine(const T &start, const U &dir)
Alternative ctor using template (3)
Definition: GeoHalfLine.h:69
virtual ~HalfLine()
Default destructor.
Definition: GeoHalfLine.h:38
Class def header for a class Point and Vector.
void Dir(const T &dir)
Dir setter template.
Definition: GeoHalfLine.h:83
const Vector_t & Dir() const
Direction getter.
Definition: GeoHalfLine.cxx:27
void Normalize()
Normalize direction.
Definition: GeoHalfLine.cxx:41
Vector Point_t
Definition: GeoVector.h:196
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
Vector Vector_t
Point has same feature as Vector.
Definition: GeoVector.h:195
list x
Definition: train.py:276
Vector_t _dir
Direction of the half line from _start.
Definition: GeoHalfLine.h:60