HerdSoftware  0.3.2
Line2D.h
Go to the documentation of this file.
1 /*
2  * Line2D.h
3  *
4  * Created on: 18 Dec 2018
5  * Author: Valerio Formato
6  */
7 
10 #ifndef HERD_LINE2D_H_
11 #define HERD_LINE2D_H_
12 
13 #ifdef HS_USE_ROOT
14 #include "Rtypes.h"
15 #endif
16 
17 // HerdSoftware headers
18 #include "common/DefaultValues.h"
19 #include "common/Exception.h"
20 #include "common/RefFrame.h"
21 #include "dataobjects/Point.h"
22 
23 namespace Herd {
24 
32 class Line2D {
33 public:
40 
43  Line2D(const Line2D &other) = default;
44 
47  Line2D(Line2D &&other) = default;
48 
51  Line2D &operator=(const Line2D &other) = default;
52 
55  Line2D &operator=(Line2D &&other) = default;
56 
66  Line2D(const Point &point, float polar);
67 
76  Line2D(const Point &point);
77 
79  virtual ~Line2D() = default;
80 
89  float Polar() const;
90 
97  inline Point Origin() const { return _point; };
98 
109  Point Intersection(float coo, RefFrame::Axis axis) const;
110 
116  inline bool IsDegenerate() const { return std::isnan(_polar); }
117 
119  class Degenerate : public Exception {
120  public:
121  using Exception::Exception;
122  };
123 
129  bool operator==(const Line2D &rhs) const { return (_polar == rhs._polar) && (_point == rhs._point); }
130 
131 private:
133  float _polar;
134 
135 #ifdef HS_USE_ROOT
136  ClassDef(Line2D, 1)
137 #endif
138 };
139 
140 } // namespace Herd
141 
142 #endif /* HERD_LINE2D_H_ */
Point Origin() const
Returns a point on the line.
Definition: Line2D.h:97
bool operator==(const Line2D &rhs) const
Comparison operator.
Definition: Line2D.h:129
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:24
bool IsDegenerate() const
Checks if the line is degenerate.
Definition: Line2D.h:116
Exception(std::string msg="")
Definition: Exception.h:30
virtual ~Line2D()=default
Virtual destructor.
Line2D & operator=(const Line2D &other)=default
Default copy assignment.
#define DEFAULT_INIT(x)
Definition: DefaultValues.h:23
Point Intersection(float coo, RefFrame::Axis axis) const
Returns the line intersection with a given line parallel to one of the main axes, passing for a given...
Definition: Line2D.cpp:36
Exception class for invalid operations on a degenerate line.
Definition: Line2D.h:119
Axis
Aliases for the axes. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:36
Class describing a line in the 2D space.
Definition: Line2D.h:32
A class describing a vector in 3D space.
Definition: Vec3D.h:33
float _polar
Definition: Line2D.h:133
Line2D()
Default constructor.
Definition: Line2D.h:39
Point _point
Definition: Line2D.h:132
Definition: Exception.h:24
float Polar() const
Returns the angle of the line with respect to the positive abscissa.
Definition: Line2D.cpp:29