HerdSoftware  0.4.0
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 
26 
27 // c++ headers
28 #include <optional>
29 
30 namespace Herd {
31 
32 class Plane;
33 
37 class Line {
38 public:
43 
46  Line(const Line &other) = default;
47 
50  Line(Line &&other) = default;
51 
54  Line &operator=(const Line &other) = default;
55 
58  Line &operator=(Line &&other) = default;
59 
67  Line(Point point, Vec3D direction) : _point{std::move(point)}, _direction{std::move(direction)} {
69  };
70 
79  Line(const Point &point, float polar, float azimuth);
80 
90  Line(const Line2D &proj1, RefFrame::View view1, const Line2D &proj2, RefFrame::View view2);
91 
93  virtual ~Line() = default;
94 
101  [[nodiscard]] inline float Polar() const { return _direction.PolarAngle(); };
102 
110  [[nodiscard]] float Azimuth() const { return _direction.AzimuthAngle(); };
111 
118  [[nodiscard]] Point Origin() const { return _point; };
119 
124  [[nodiscard]] Vec3D Direction() const { return _direction; };
125 
127  class Degenerate : public Exception {
128  public:
129  using Exception::Exception;
130  };
131 
138  [[nodiscard]] std::optional<Point> Intersection(RefFrame::Axis axis, float coo) const;
139 
146  [[nodiscard]] std::optional<Point> Intersection(const Line &line) const;
147 
153  [[nodiscard]] Line Projection(const Plane &plane) const;
154 
161  [[nodiscard]] Line Projection(const Point p, RefFrame::View view) const;
162 
168  [[nodiscard]] Line2D Projection2D(RefFrame::View view) const;
169 
175  [[nodiscard]] double DistanceToPoint(const Point p) const;
176 
182  [[nodiscard]] double MinimumDistanceToLine(const Line line) const;
183 
189  bool operator==(const Line &rhs) const { return (_point == rhs._point) && (_direction == rhs._direction); }
190  bool operator!=(const Line &rhs) const { return !(*this == rhs); }
191 
192 private:
195 
196 #ifdef HS_USE_ROOT
197  ClassDef(Line, 2)
198 #endif
199 };
200 
201 } // namespace Herd
202 
203 #endif /* HERD_LINE_H_ */
Herd::Vec3D::Mag
float Mag() const
Compute the vector magnitude.
Definition: Vec3D.h:118
Herd::Plane
Class describing a Plane in the 3D space.
Definition: Plane.h:29
Point.h
Herd::Line::Polar
float Polar() const
Returns the polar angle of the line with respect to the NEGATIVE Z axis.
Definition: Line.h:101
Herd::Line::_point
Point _point
Definition: Line.h:193
Herd::Line::Direction
Vec3D Direction() const
Returns direction of the line.
Definition: Line.h:124
Herd::Vec3D
A class describing a vector in 3D space.
Definition: Vec3D.h:33
Herd::Line::operator==
bool operator==(const Line &rhs) const
Comparison operators.
Definition: Line.h:189
Herd::Line::Origin
Point Origin() const
Returns the "point of origin" of the line.
Definition: Line.h:118
DEFAULT_INIT
#define DEFAULT_INIT(x)
Definition: DefaultValues.h:23
Herd::Line
Class describing a line in the 3D space.
Definition: Line.h:37
Herd::Line::MinimumDistanceToLine
double MinimumDistanceToLine(const Line line) const
Computes the minimum distance between two lines.
Definition: Line.cpp:213
Herd::Line::Degenerate
Exception class for invalid operations on a degenerate line.
Definition: Line.h:127
Herd::Line::DistanceToPoint
double DistanceToPoint(const Point p) const
Computes the distance of a point to the line.
Definition: Line.cpp:207
Herd::Vec3D::AzimuthAngle
float AzimuthAngle() const
Compute the azimuth angle.
Definition: Vec3D.h:166
Herd::Line::_direction
Vec3D _direction
Definition: Line.h:194
Herd::Exception::Exception
Exception(std::string msg="")
Definition: Exception.h:30
Vec3D.h
Herd
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:22
Herd::RefFrame::View
View
Aliases for the three 2D projection planes.
Definition: RefFrame.h:91
Herd::Line::Azimuth
float Azimuth() const
Returns the azimuth angle of the line.
Definition: Line.h:110
Exception.h
Herd::Vec3D::PolarAngle
float PolarAngle() const
Compute the polar angle.
Definition: Vec3D.h:156
RefFrame.h
Herd::Line::operator=
Line & operator=(const Line &other)=default
Default copy assignment.
Herd::Line::operator!=
bool operator!=(const Line &rhs) const
Definition: Line.h:190
Herd::Line::Projection2D
Line2D Projection2D(RefFrame::View view) const
Computes the 2D projection of the line on a given view.
Definition: Line.cpp:252
Line2D.h
Herd::Line::Intersection
std::optional< 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
Herd::Exception
Definition: Exception.h:24
Herd::RefFrame::Axis
Axis
Aliases for the axes.
Definition: RefFrame.h:34
Point
A class describing a point in the 3D space.
DefaultValues.h
Herd::Line2D
Class describing a line in the 2D space.
Definition: Line2D.h:35
Herd::Line::Line
Line()
Default Constructor.
Definition: Line.h:42
Herd::Line::Line
Line(Point point, Vec3D direction)
Constructor.
Definition: Line.h:67
Herd::Line::Projection
Line Projection(const Plane &plane) const
Computes the projection of the line on a given plane.
Definition: Line.cpp:223
Herd::Line::~Line
virtual ~Line()=default
Virtual destructor