Skip to content

pygeo.create_triangulation

fabian-flassig edited this page May 27, 2026 · 3 revisions

Computes a 2D Delaunay triangulation of a set of input points.

This function is located in the pygeo module.

The function performs a purely geometric computation in the local u/v plane and does not create any elements in the project. An optional list of constraint edges may be supplied to perform a constrained Delaunay triangulation, which guarantees that each given edge appears as an edge of the resulting triangle mesh.

pygeo.create_triangulation(points [,edges])
Parameter Type Description
points {{u,v}, ...} Coordinates of the input points in 2D. At least three points are required. Points must be pairwise distinct.
edges {{i1,i2}, ...} Optional: constraint edges as pairs of 1-based indices into points. Each given edge is guaranteed to appear in the resulting triangulation. Constraint edges must not cross each other in their interiors. If omitted, an unconstrained Delaunay triangulation is computed.

Return values

Type Description
triangles {{p1,p2,p3}, ...}
triangle_edges {{k1,k2,k3}, ...}
triangle_neighbours {{n1,n2,n3}, ...}

Notes:

  • The triangulation covers the convex hull of points. If the result must be restricted to a polygonal region with holes, filter the returned triangles against the region after the call.
  • Constraint edges may reference any pair of points; they are not restricted to a closed outline. Multiple boundary loops can be passed together to triangulate regions with holes.
  • Duplicate or near-duplicate points cause the triangulation to fail.
  • The function operates on 2D coordinates in the u/v plane only. To work in 3D, project the points into a local plane using push_local_coordinates and lift the result back afterwards.

Example:

local points = {
    -- outer rectangle
    {0.0, 0.0}, {4.0, 0.0}, {4.0, 3.0}, {0.0, 3.0},
    -- inner hole
    {1.5, 1.0}, {2.5, 1.0}, {2.5, 2.0}, {1.5, 2.0},
}

local edges = {
    {1, 2}, {2, 3}, {3, 4}, {4, 1},
    {5, 6}, {6, 7}, {7, 8}, {8, 5},
}

local triangles, triangle_edges, triangle_neighbours =
    pygeo.create_triangulation(points, edges)

for _, tri in ipairs(triangles) do
    local a = points[tri[1]]
    local b = points[tri[2]]
    local c = points[tri[3]]
    -- ... use a, b, c
end

Version Support:

Minimum PYTHA Version: V27

See also:

pygeo, pygeo.clean_polygon_2d_ex, pytha.create_polygon_ex, pytha.push_local_coordinates

Clone this wiki locally