HerdSoftware  0.4.0
Triangle.h
Go to the documentation of this file.
1 /*
2  * Triangle.h
3  *
4  * Created on: 9 Feb 2023
5  * Author: Valerio Formato
6  */
7 
10 #ifndef HERD_TRIANGLE_H_
11 #define HERD_TRIANGLE_H_
12 
15 
21 namespace Herd {
22 class Triangle {
23 public:
28  Triangle() = default;
29 
31  virtual ~Triangle() = default;
32 
40  Triangle(std::array<Point, 3> points);
41 
48  [[nodiscard]] Herd::Plane Plane() const { return m_plane; };
49 
56  [[nodiscard]] std::array<Point, 3> Vertices() const;
57 
65  [[nodiscard]] std::optional<Point> Intersection(const Line &line) const;
66 
74  [[nodiscard]] bool Contains(Point point) const;
75 
81  bool operator==(const Triangle &rhs) const { return m_plane == rhs.m_plane && m_vertices == rhs.m_vertices; }
82 
83  bool operator!=(const Triangle &rhs) const { return !operator==(rhs); }
84 
85 protected:
86  Herd::Plane m_plane; // The origin of this plane lies on one vertex of the Triangle
87  std::array<Vec3D, 2> m_vertices; // Coordinates of the vertices w.r.t. the origin of the plane
88 
89 #ifdef HS_USE_ROOT
90  ClassDef(Triangle, 1)
91 #endif
92 };
93 } // namespace Herd
94 
95 #endif // HERD_TRIANGLE_H_
Herd::Plane
Class describing a Plane in the 3D space.
Definition: Plane.h:29
Herd::Triangle::Contains
bool Contains(Point point) const
Checks if the Triangle contains the given point.
Definition: Triangle.cpp:29
Point.h
Herd::Vec3D
A class describing a vector in 3D space.
Definition: Vec3D.h:33
Herd::Line
Class describing a line in the 3D space.
Definition: Line.h:37
Herd::Triangle::Intersection
std::optional< Point > Intersection(const Line &line) const
Computes the intersection point of the given line with the Triangle.
Definition: Triangle.cpp:53
Herd::Triangle::Vertices
std::array< Point, 3 > Vertices() const
Gets the vertices of the Triangle.
Definition: Triangle.cpp:24
Plane.h
Herd
CssGeoParams.h CssGeoParams class declaration.
Definition: CaloPDCalibrationAlgo.h:22
Herd::Triangle::operator==
bool operator==(const Triangle &rhs) const
Comparison operator.
Definition: Triangle.h:81
Herd::Triangle::m_vertices
std::array< Vec3D, 2 > m_vertices
Definition: Triangle.h:87
Herd::Triangle::operator!=
bool operator!=(const Triangle &rhs) const
Definition: Triangle.h:83
Herd::Triangle::Plane
Herd::Plane Plane() const
Gets the plane on which the Triangle lies.
Definition: Triangle.h:48
Herd::Triangle::~Triangle
virtual ~Triangle()=default
Destructor.
Herd::Triangle::Triangle
Triangle()=default
Herd::Triangle
Definition: Triangle.h:22
Herd::Triangle::m_plane
Herd::Plane m_plane
Definition: Triangle.h:86