![]() |
Vulpes
0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
|
Signed distance function for a polygon in 2D space. More...
#include <distance.hpp>
Public Member Functions | |
| PolygonDistance (const std::vector< Point< FloatType, 2 > > &vertices) | |
| Constructor for the polygon distance function. | |
| void | operator() (const Point< FloatType, 2 > &point, FloatType *distance_buffer) const |
| Compute the signed distance between a point and the polygon. | |
| std::array< Point< FloatType, 2 >, 2 > | bbox () const |
| Get the bounding box of the polygon. | |
| void | operator() (const Point< FloatType, Dim > &point, FloatType *distance_buffer) const |
| Evaluate the distance function for the given point. | |
Static Public Member Functions | |
| static constexpr size_t | size () |
| Get the size of the distance buffer for this distance function. | |
Static Public Attributes | |
| static constexpr size_t | max_edges = 2000 |
| Largest number of edges: the buffer size is a compile-time constant. | |
| static constexpr bool | is_leaf = true |
| A flag indicating that this is a leaf node in a composite expression. Indeed we give an explicit formula to compute the distance. | |
Private Member Functions | |
| bool | hasIntersectingEdges () const |
| True if two edges that are not consecutive cross or touch. | |
Private Attributes | |
| const std::vector< Point< FloatType, 2 > > | m_vertices |
| The vertices of the polygon. | |
| FloatType | m_outward_sign |
| Makes the edge distances positive outward. | |
Signed distance function for a polygon in 2D space.
This class computes the signed distance between a point and a polygon, convex or concave, without holes and without self-intersections. The distance is negative inside the polygon and on its boundary, positive outside, and its magnitude is the distance to the closest point of the boundary.
The buffer also holds, for each edge, the signed distance to the line through that edge, negative on the inner side: VulPoly reflects the seeds across these lines, whose normal stays constant near the corners. The slots after the last edge hold the largest value, so that VulPoly ignores them.
| FloatType | The type of floating-point value. |
|
inlineexplicit |
Constructor for the polygon distance function.
| vertices | The vertices in order, in either orientation, without repeating the first one at the end. |
| std::invalid_argument | if there are fewer than 3 or more than max_edges vertices, if the enclosed area is zero, or if two edges that are not consecutive cross or touch. |
|
inline |
Get the bounding box of the polygon.
|
inlineprivate |
True if two edges that are not consecutive cross or touch.
|
inline |
Compute the signed distance between a point and the polygon.
| point | The point for which the distance is to be computed. |
| distance_buffer | The buffer where the computed distances will be stored. |
|
inlineinherited |
Evaluate the distance function for the given point.
This function computes the signed distance between a point and the shape defined by the Distance type. The result is stored in the provided distance_buffer.
| point | The point for which the distance needs to be computed. |
| distance_buffer | The buffer where the computed distances will be stored. |
|
inlinestaticconstexpr |
Get the size of the distance buffer for this distance function.
|
staticconstexpr |
A flag indicating that this is a leaf node in a composite expression. Indeed we give an explicit formula to compute the distance.
|
private |
Makes the edge distances positive outward.
|
private |
The vertices of the polygon.
|
staticconstexpr |
Largest number of edges: the buffer size is a compile-time constant.