AsImpL 1.0
Asynchronous Importer and run-time Loader for Unity
AsImpL.MathUtil.Triangulation Class Reference

Static Public Member Functions

static List< TriangleTriangulateConvexPolygon (List< Vertex > vertices, bool preserveOriginalVertices=true)
 Triangulate a convex polygon maximizing its triangles areas. More...
 
static List< TriangleTriangulateByEarClipping (List< Vertex > origVertices, Vector3 planeNormal, string meshName, bool preserveOriginalVertices=true)
 Triangulate a ploygon using ear clipping algorithm. More...
 
static Triangle ClipTriangle (Vertex vertex, List< Vertex > vertices)
 

Member Function Documentation

◆ ClipTriangle()

static Triangle AsImpL.MathUtil.Triangulation.ClipTriangle ( Vertex  vertex,
List< Vertex vertices 
)
static

◆ TriangulateByEarClipping()

static List< Triangle > AsImpL.MathUtil.Triangulation.TriangulateByEarClipping ( List< Vertex origVertices,
Vector3  planeNormal,
string  meshName,
bool  preserveOriginalVertices = true 
)
static

Triangulate a ploygon using ear clipping algorithm.

Parameters
origVerticesVertices of the polygon in 3D (assumed to be convex or concave).
planeNormalThis is basically a 2D algorithm, this is the normal of the plane used to project 3D vertices in 2D.
meshName
preserveOriginalVertices
Returns
List of triangles as a result of the triangulation process.

Derived (adapted/refactored) from: https://www.habrador.com/tutorials/math/10-triangulation/. The points on the polygon should be ordered counter-clockwise. The ear clipping algorithm is O(n*n), another common algorithm is dividing it into trapezoids and it's O(n log n), one can maybe do it in O(n) time but no such version is known. Assumes we have at least 4 points.

◆ TriangulateConvexPolygon()

static List< Triangle > AsImpL.MathUtil.Triangulation.TriangulateConvexPolygon ( List< Vertex vertices,
bool  preserveOriginalVertices = true 
)
static

Triangulate a convex polygon maximizing its triangles areas.

Parameters
verticesVertices of the polygon (assumed to be convex).
preserveOriginalVerticesIf true a copy is made to preserve the original list of vertices.
Returns
List of computed triangles.

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