-
Notifications
You must be signed in to change notification settings - Fork 18
pygeo.create_triangulation
Daniel Flassig edited this page Jul 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. |
| Type | Description |
|---|---|
triangles |
{{p1,p2,p3}, ...} |
triangle_edges |
{{k1,k2,k3}, ...} |
triangle_neighbours |
{{n1,n2,n3}, ...} |
- 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. Constaint edges may, however, not intersect.
- Duplicate points cause the triangulation to fail.
- The function operates on 2D coordinates in the
u/vplane only. To work in 3D, project the points into a local plane usingpush_local_coordinatesand lift the result back afterwards.
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
endMinimum PYTHA Version: V27
pygeo, pygeo.clean_polygon_2d_ex, pytha.create_polygon_ex, pytha.push_local_coordinates