ImFusion SDK 4.3
Polygon2D Class Reference

#include <ImFusion/Core/Geometry/Polygon.h>

Class representing a planar polygon. More...

Detailed Description

Class representing a planar polygon.

See also
Intersections between geometry primitives can be computed using the sets of free functions Geometry::intersection() and Geometry::intersects().

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.
 

Constructor & Destructor Documentation

◆ Polygon2D()

Polygon2D ( std::vector< vec2 > points)

Constructs the polygon from sorted boundary points.

If adjacent points have the same position, the duplicate will be discarded.

Member Function Documentation

◆ isEquivalent()

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.

◆ triangulate()

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.

◆ includesPoint()

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.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close