EBGeometry  1.0
Public Types | Public Member Functions | List of all members
Polygon2D< T > Class Template Reference

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...
 

Detailed Description

template<class T>
class Polygon2D< T >

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.

Constructor & Destructor Documentation

◆ Polygon2D()

template<class T >
Polygon2D< T >::Polygon2D ( const Vec3 a_normal,
const std::vector< Vec3 > &  a_points 
)

Full constructor.

Parameters
[in]a_normalNormal vector of the 3D polygon face
[in]a_pointsVertex coordinates of the 3D polygon face

Member Function Documentation

◆ isPointInside()

template<class T >
bool Polygon2D< T >::isPointInside ( const Vec3 a_point,
const InsideOutsideAlgorithm  a_algorithm 
) const
inlinenoexcept

Check if a point is inside or outside the 2D polygon.

Parameters
[in]a_point3D point coordinates
[in]a_algorithmInside/outside algorithm

This will call the function corresponding to a_algorithm.

◆ isPointInsidePolygonCrossingNumber()

template<class T >
bool Polygon2D< T >::isPointInsidePolygonCrossingNumber ( const Vec3 a_point) const
inlinenoexcept

Check if a point is inside a 2D polygon, by computing the number of times a ray crosses the polygon edges.

Parameters
[in]a_point3D point coordinates
Returns
Returns true if the 3D point projects to the inside of the 2D polygon

◆ isPointInsidePolygonSubtend()

template<class T >
bool Polygon2D< T >::isPointInsidePolygonSubtend ( const Vec3 a_point) const
inlinenoexcept

Check if a point is inside a 2D polygon, using the subtended angles.

Parameters
[in]a_point3D point coordinates
Returns
Returns true if the 3D point projects to the inside of the 2D polygon

◆ isPointInsidePolygonWindingNumber()

template<class T >
bool Polygon2D< T >::isPointInsidePolygonWindingNumber ( const Vec3 a_point) const
inlinenoexcept

Check if a point is inside a 2D polygon, using the winding number algorithm.

Parameters
[in]a_point3D point coordinates
Returns
Returns true if the 3D point projects to the inside of the 2D polygon

The documentation for this class was generated from the following file: