![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/Geometry/Polygon.h>
Class representing a planar polygon. More...
Class representing a planar polygon.
Public Member Functions | |
| Polygon2D (std::vector< vec2 > points) | |
| Constructs the polygon from sorted boundary points. | |
| bool | operator== (const Polygon2D &other) const |
| bool | operator!= (const Polygon2D &other) const |
| bool | isApprox (const Polygon2D &other) const |
| bool | isEquivalent (const Polygon2D &other) const |
| Returns whether the Polygon2Ds represent the same boundary. | |
| const std::vector< vec2 > & | points () const |
| bool | isSimple () const |
| Returns whether the polygon is simple, which means: None of the edge segments intersect (except for neighbouring segments touching at the connecting point), each of these connecting vertices is part of exactly 2 segments, and the enclosed area is finite and not zero. | |
| std::vector< vec3i > | triangulate () const |
| Splits the enclosed space into triangles defined by vertices of the polygon. | |
| bool | includesPoint (const vec2 &point) const |
| Returns whether the point is inside the polygon. | |
| Polygon2D | ( | std::vector< vec2 > | points | ) |
Constructs the polygon from sorted boundary points.
If adjacent points have the same position, the duplicate will be discarded.
| bool isEquivalent | ( | const Polygon2D & | other | ) | const |
Returns whether the Polygon2Ds represent the same boundary.
Note that this is still the case if the points are reversed or shifted inside the array.
| std::vector< vec3i > triangulate | ( | ) | const |
Splits the enclosed space into triangles defined by vertices of the polygon.
The vertices are chosen to minimize triangle areas. If triangulation is not possible due to lack of vertices or part of the polygon not being finite, an empty vector is returned. Note that the returned indices correspond to the points currently held by this object, which is not necessarily the same list of points that was passed into the constructor originally.
| bool includesPoint | ( | const vec2 & | point | ) | const |
Returns whether the point is inside the polygon.
The result for points extremely close to the boundary is undefined, with extremely close being a range of about 1e-15 times the largest involved coordinate.