EBGeometry 1.0
Loading...
Searching...
No Matches
EBGeometry_Triangle2D.hpp
Go to the documentation of this file.
1/* EBGeometry
2 * Copyright © 2024 Robert Marskar
3 * Please refer to Copyright.txt and LICENSE in the EBGeometry root directory.
4 */
12#ifndef EBGeometry_Triangle2D
13#define EBGeometry_Triangle2D
14
15// Std includes
16#include <array>
17
18// Our includes
19#include "EBGeometry_Vec.hpp"
20
21namespace EBGeometry {
36 template <class T>
38 {
39 public:
43 using Vec2 = Vec2T<T>;
44
48 using Vec3 = Vec3T<T>;
49
54 enum class InsideOutsideAlgorithm // NOLINT
55 {
56 SubtendedAngle,
57 CrossingNumber,
58 WindingNumber
59 };
60
65
72
78
84
89
96
103
109 void
111
118 bool
120
128 bool
130
138 bool
140
147 bool
149
150 private:
154 int m_xDir = -1;
155
159 int m_yDir = -1;
160
165 std::array<Vec2, 2> m_vertices{Vec2::max(), Vec2::max()};
166
173 Vec2
174 projectPoint(const Vec3& a_point) const noexcept;
175
181 int
182 computeWindingNumber(const Vec2& a_point) const noexcept;
183
189 int
190 computeCrossingNumber(const Vec2& a_point) const noexcept;
191
197 T
198 computeSubtendedAngle(const Vec2& a_point) const noexcept;
199 };
200} // namespace EBGeometry
201
202#include "EBGeometry_Triangle2DImplem.hpp" // NOLINT
203
204#endif
Declaration of 2D and 3D point/vector classes with templated precision. Used with DCEL tools.
Class for embedding a triangle face into 2D.
Definition EBGeometry_Triangle2D.hpp:38
bool isPointInsideSubtend(const Vec3 &a_point) const noexcept
Check if a point is inside a 2D polygon, using the subtended angles.
bool isPointInside(const Vec3 &a_point, InsideOutsideAlgorithm a_algorithm) const noexcept
Check if a point is inside or outside the 2D polygon.
bool isPointInsideWindingNumber(const Vec3 &a_point) const noexcept
Check if a point is inside a 2D polygon, using the winding number algorithm.
bool isPointInsideCrossingNumber(const Vec3 &a_point) const noexcept
Check if a point is inside a 2D polygon, by computing the number of times a ray crosses the polygon e...
InsideOutsideAlgorithm
Supported algorithms for performing inside/outside tests when checking if a point projects to the ins...
Definition EBGeometry_Triangle2D.hpp:55
Triangle2D() noexcept=default
Default constructor. Must subsequently call the define function.
Vec3T< T > Vec3
Alias for 3D vector type.
Definition EBGeometry_Triangle2D.hpp:48
Vec2T< T > Vec2
Alias for 2D vector type.
Definition EBGeometry_Triangle2D.hpp:43
void define(const Vec3 &a_normal, const std::array< Vec3, 3 > &a_vertices) noexcept
Define function. Puts object in usable state.
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:218
static constexpr Vec3T< T > max() noexcept
Return a vector with maximum representable components.
Name space for all of EBGeometry.
Definition EBGeometry.hpp:23