Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::Polygon2DTriangulator< IndexType > Class Template Reference

#include <AdvancedMath.hpp>

Public Member Functions

template<typename ComponentType>
const std::vector< IndexType > & Triangulate (const std::vector< Vector2< ComponentType > > &Polygon)
 Triangulates a simple polygon using the ear-clipping algorithm.
 

Detailed Description

template<typename IndexType>
class Diligent::Polygon2DTriangulator< IndexType >

2D polygon triangulator.

The class implements the ear-clipping algorithm to triangulate simple (i.e. non-self-intersecting) 2D polygons.

Template Parameters
IndexType- Index type (e.g. Uint32 or Uint16).

Member Function Documentation

◆ Triangulate()

template<typename IndexType>
template<typename ComponentType>
const std::vector< IndexType > & Diligent::Polygon2DTriangulator< IndexType >::Triangulate ( const std::vector< Vector2< ComponentType > > & Polygon)
inline

Triangulates a simple polygon using the ear-clipping algorithm.

Template Parameters
[in]ComponentType - Vertex component type (e.g. float, double or int).
Parameters
[in]Polygon- A list of polygon vertices. The last vertex is assumed to be connected to the first one
Returns
The triangle list.

The winding order of each triangle is the same as the winding order of the polygon.

The function does not check if the polygon is simple, e.g. that it does not self-intersect.