HerdSoftware  0.4.0
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
22 
23 // c++ headers
24 #include <optional>
25 
26 namespace Herd {
27 
35 class Line2D {
36 public:
43 
46  Line2D(const Line2D &other) = default;
47 
50  Line2D(Line2D &&other) = default;
51 
54  Line2D &operator=(const Line2D &other) = default;
55 
58  Line2D &operator=(Line2D &&other) = default;
59 
69  Line2D(const Point &point, float polar);
70 
79  Line2D(const Point &point);
80 
82  virtual ~Line2D() = default;
83 
92  [[nodiscard]] float Polar() const;
93 
100  [[nodiscard]] inline Point Origin() const { return _point; };
101 
112  [[nodiscard]] std::optional<Point> Intersection(float coo, RefFrame::Axis axis) const;
113 
119  [[nodiscard]] inline bool IsDegenerate() const { return std::isnan(_polar); }
120 
122  class Degenerate : public Exception {
123  public:
124  using Exception::Exception;
125  };
126 
132  bool operator==(const Line2D &rhs) const { return (_polar == rhs._polar) && (_point == rhs._point); }
133 
134 private:
136  float _polar;
137 
138 #ifdef HS_USE_ROOT
139  ClassDef(Line2D, 1)
140 #endif
141 };
142 
143 } // namespace Herd
144 
145 #endif /* HERD_LINE2D_H_ */
Point.h
Herd::Line2D::_point
Point _point
Definition: Line2D.h:135
Herd::Vec3D
A class describing a vector in 3D space.
Definition: Vec3D.h:33
DEFAULT_INIT
#define DEFAULT_INIT(x)
Definition: DefaultValues.h:23
Herd::Line2D::IsDegenerate
bool IsDegenerate() const
Checks if the line is degenerate.
Definition: Line2D.h:119
Herd::Line2D::Polar
float Polar() const
Returns the angle of the line with respect to the positive abscissa.
Definition: Line2D.cpp:29
Herd::Exception::Exception
Exception(std::string msg="")
Definition: Exception.h:30
Herd
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:22
Exception.h
RefFrame.h
Herd::Line2D::Origin
Point Origin() const
Returns a point on the line.
Definition: Line2D.h:100
Herd::Exception
Definition: Exception.h:24
Herd::Line2D::Line2D
Line2D()
Default constructor.
Definition: Line2D.h:42
Herd::RefFrame::Axis
Axis
Aliases for the axes.
Definition: RefFrame.h:34
Herd::Line2D::operator=
Line2D & operator=(const Line2D &other)=default
Default copy assignment.
Herd::Line2D::~Line2D
virtual ~Line2D()=default
Virtual destructor
DefaultValues.h
Herd::Line2D::Degenerate
Exception class for invalid operations on a degenerate line.
Definition: Line2D.h:122
Herd::Line2D
Class describing a line in the 2D space.
Definition: Line2D.h:35
Herd::Line2D::operator==
bool operator==(const Line2D &rhs) const
Comparison operator.
Definition: Line2D.h:132
Herd::Line2D::Intersection
std::optional< 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
Herd::Line2D::_polar
float _polar
Definition: Line2D.h:136