EBGeometry
1.0
|
Class for embedding a polygon face into 2D. More...
#include <EBGeometry_Polygon2D.hpp>
Public Types | |
enum class | InsideOutsideAlgorithm { SubtendedAngle , CrossingNumber , WindingNumber } |
Supported algorithms for performing inside/outside tests when checking if a point projects to the inside or outside of a polygon face. | |
using | Vec2 = Vec2T< T > |
Alias to cut down on typing. | |
using | Vec3 = Vec3T< T > |
Alias to cut down on typing. | |
Public Member Functions | |
Polygon2D ()=delete | |
Disallowed constructor, use the one with the normal vector and points. | |
Polygon2D (const Vec3 &a_normal, const std::vector< Vec3 > &a_points) | |
Full constructor. More... | |
~Polygon2D ()=default | |
Destructor (does nothing. | |
bool | isPointInside (const Vec3 &a_point, const InsideOutsideAlgorithm a_algorithm) const noexcept |
Check if a point is inside or outside the 2D polygon. More... | |
bool | isPointInsidePolygonWindingNumber (const Vec3 &a_point) const noexcept |
Check if a point is inside a 2D polygon, using the winding number algorithm. More... | |
bool | isPointInsidePolygonSubtend (const Vec3 &a_point) const noexcept |
Check if a point is inside a 2D polygon, using the subtended angles. More... | |
bool | isPointInsidePolygonCrossingNumber (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 edges. More... | |
Class for embedding a polygon face into 2D.
This class is required for determining whether or not a 3D point projected to the plane of an N-sided polygon lies inside or outside the polygon face. To do this we compute the 2D embedding of the polygon face, reducing the problem to a tractable dimension where we can use well-tested algorithm. The 2D embedding of a polygon occurs by taking a set of 3D points and a corresponding normal vector, and projecting those points along one of the 3D Cartesian axes such that the polygon has the largest area. In essence, we simply find the direction with the smallest normal vector component and ignore that. Once the 2D embedding is computed, we can use well-known algorithms for checking if a point lies inside or outside. The supported algorithms are 1) The winding number algorithm (computing the winding number), 2) Computing the subtended angle of the point with the edges of the polygon (sums to 360 degrees if the point is inside), or computing the crossing number which checks how many times a ray cast from the point crosses the edges of the polygon.
Polygon2D< T >::Polygon2D | ( | const Vec3 & | a_normal, |
const std::vector< Vec3 > & | a_points | ||
) |
Full constructor.
[in] | a_normal | Normal vector of the 3D polygon face |
[in] | a_points | Vertex coordinates of the 3D polygon face |
|
inlinenoexcept |
Check if a point is inside or outside the 2D polygon.
[in] | a_point | 3D point coordinates |
[in] | a_algorithm | Inside/outside algorithm |
This will call the function corresponding to a_algorithm.
|
inlinenoexcept |
Check if a point is inside a 2D polygon, by computing the number of times a ray crosses the polygon edges.
[in] | a_point | 3D point coordinates |
|
inlinenoexcept |
Check if a point is inside a 2D polygon, using the subtended angles.
[in] | a_point | 3D point coordinates |
|
inlinenoexcept |
Check if a point is inside a 2D polygon, using the winding number algorithm.
[in] | a_point | 3D point coordinates |