|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
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. More... | |
| using | Vec2 = Vec2T< T > |
| Alias for the 2D vector type used for the projected polygon points. | |
| using | Vec3 = Vec3T< T > |
| Alias for the 3D vector type used for the polygon's original (unprojected) points. | |
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. | |
| Polygon2D (const Polygon2D &a_other)=default | |
| Copy constructor. | |
| Polygon2D (Polygon2D &&a_other) noexcept=default | |
| Move constructor. | |
| ~Polygon2D ()=default | |
| Destructor. | |
| Polygon2D & | operator= (const Polygon2D &a_other)=default |
| Copy assignment operator. | |
| Polygon2D & | operator= (Polygon2D &&a_other) noexcept=default |
| Move assignment operator. | |
| bool | isPointInside (const Vec3 &a_point, const InsideOutsideAlgorithm a_algorithm) const noexcept |
| Check if a point is inside or outside the 2D polygon. | |
| bool | isPointInsidePolygonWindingNumber (const Vec3 &a_point) const noexcept |
| Check if a point is inside a 2D polygon, using the winding number algorithm. | |
| bool | isPointInsidePolygonSubtend (const Vec3 &a_point) const noexcept |
| Check if a point is inside a 2D polygon, using the subtended angles. | |
| 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. | |
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.
| T | Floating-point precision. |
|
strong |
Supported algorithms for performing inside/outside tests when checking if a point projects to the inside or outside of a polygon face.
| Enumerator | |
|---|---|
| SubtendedAngle | Sums the subtended angle of the point with each polygon edge; the point is inside if the sum is +-2*pi (360 degrees) and outside if it is 0. See isPointInsidePolygonSubtend() and computeSubtendedAngle(). |
| CrossingNumber | Casts a ray from the point along +x and counts how many times it crosses a polygon edge; the point is inside if the crossing count is odd (even-odd rule). See isPointInsidePolygonCrossingNumber() and computeCrossingNumber(). |
| WindingNumber | Computes the winding number of the polygon boundary around the point; the point is inside if the winding number is non-zero. See isPointInsidePolygonWindingNumber() and computeWindingNumber(). |
| EBGeometry::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. Must be finite and non-degenerate (length > 0). |
| [in] | a_points | Vertex coordinates of the 3D polygon face. Must have at least 3 points. |
|
default |
Copy constructor.
| [in] | a_other | Other polygon. |
|
defaultnoexcept |
Move constructor.
| [in,out] | a_other | Other polygon. |
|
inlinenoexcept |
Check if a point is inside or outside the 2D polygon.
| [in] | a_point | 3D point coordinates. |
| [in] | a_algorithm | Inside/outside algorithm to use. |
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 |
|
default |
Copy assignment operator.
| [in] | a_other | Other polygon. |
|
defaultnoexcept |
Move assignment operator.
| [in,out] | a_other | Other polygon. |