HerdSoftware  0.3.2
Line.h
Go to the documentation of this file.
1 /*
2  * Line.h
3  *
4  * Created on: 19 Oct 2018
5  * Author: Nicola Mori
6  */
7 
10 #ifndef HERD_LINE_H_
11 #define HERD_LINE_H_
12 
13 #ifdef HS_USE_ROOT
14 #include "Rtypes.h"
15 #endif
16 
17 // HerdSoftware headers
18 #include <utility>
19 
20 #include "common/DefaultValues.h"
21 #include "common/Exception.h"
22 #include "common/RefFrame.h"
23 #include "common/Vec3D.h"
24 #include "dataobjects/Line2D.h"
25 #include "dataobjects/Point.h"
26 
27 namespace Herd {
28 
29 class Plane;
30 
34 class Line {
35 public:
40 
43  Line(const Line &other) = default;
44 
47  Line(Line &&other) = default;
48 
51  Line &operator=(const Line &other) = default;
52 
55  Line &operator=(Line &&other) = default;
56 
64  Line(Point point, Vec3D direction) : _point{std::move(point)}, _direction{std::move(direction)} {
66  };
67 
76  Line(const Point &point, float polar, float azimuth);
77 
87  Line(const Line2D &proj1, RefFrame::View view1, const Line2D &proj2, RefFrame::View view2);
88 
90  virtual ~Line() = default;
91 
98  inline float Polar() const { return _direction.PolarAngle(); };
99 
107  float Azimuth() const { return _direction.AzimuthAngle(); };
108 
115  Point Origin() const { return _point; };
116 
121  Vec3D Direction() const { return _direction; };
122 
124  class Degenerate : public Exception {
125  public:
126  using Exception::Exception;
127  };
128 
136  Point Intersection(RefFrame::Axis axis, float coo) const;
137 
145  Point Intersection(const Line &line) const;
146 
152  Line Projection(const Plane &plane) const;
153 
160  Line Projection(const Point p, RefFrame::View view) const;
161 
167  Line2D Projection2D(RefFrame::View view) const;
168 
174  double DistanceToPoint(const Point p) const;
175 
181  double MinimumDistanceToLine(const Line line) const;
182 
188  bool operator==(const Line &rhs) const { return (_point == rhs._point) && (_direction == rhs._direction); }
189  bool operator!=(const Line &rhs) const { return !(*this == rhs); }
190 
191 private:
194 
195 #ifdef HS_USE_ROOT
196  ClassDef(Line, 2)
197 #endif
198 };
199 
200 } // namespace Herd
201 
202 #endif /* HERD_LINE_H_ */
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:24
Exception(std::string msg="")
Definition: Exception.h:30
#define DEFAULT_INIT(x)
Definition: DefaultValues.h:23
Line2D Projection2D(RefFrame::View view) const
Computes the 2D projection of the line on a given view.
Definition: Line.cpp:252
Vec3D _direction
Definition: Line.h:193
float Polar() const
Returns the polar angle of the line with respect to the NEGATIVE Z axis.
Definition: Line.h:98
Vec3D Direction() const
Returns direction of the line.
Definition: Line.h:121
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
double MinimumDistanceToLine(const Line line) const
Computes the minimum distance between two lines.
Definition: Line.cpp:213
Point Origin() const
Returns the "point of origin" of the line.
Definition: Line.h:115
float PolarAngle() const
Compute the polar angle.
Definition: Vec3D.h:147
A class describing a vector in 3D space.
Definition: Vec3D.h:33
Class describing a line in the 3D space.
Definition: Line.h:34
virtual ~Line()=default
Virtual destructor.
Line Projection(const Plane &plane) const
Computes the projection of the line on a given plane.
Definition: Line.cpp:223
bool operator==(const Line &rhs) const
Comparison operators.
Definition: Line.h:188
float AzimuthAngle() const
Compute the azimuth angle.
Definition: Vec3D.h:157
Point _point
Definition: Line.h:192
double DistanceToPoint(const Point p) const
Computes the distance of a point to the line.
Definition: Line.cpp:207
Line()
Default Constructor.
Definition: Line.h:39
Point Intersection(RefFrame::Axis axis, float coo) const
Returns the line coordinate at given plane, defined by its normal axis and the coordinate along that ...
Definition: Line.cpp:173
float Mag() const
Compute the vector magnitude.
Definition: Vec3D.h:118
Line(Point point, Vec3D direction)
Constructor.
Definition: Line.h:64
Definition: Exception.h:24
Exception class for invalid operations on a degenerate line.
Definition: Line.h:124
float Azimuth() const
Returns the azimuth angle of the line.
Definition: Line.h:107
View
Aliases for the three 2D projection planes. RefFrame.h common/RefFrame.h.
Definition: RefFrame.h:93
Class describing a Plane in the 3D space.
Definition: Plane.h:28
Line & operator=(const Line &other)=default
Default copy assignment.
bool operator!=(const Line &rhs) const
Definition: Line.h:189