File: triangulate2d.py

package info (click to toggle)
vedo 2025.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,404 kB
  • sloc: python: 64,792; javascript: 1,932; xml: 437; sh: 139; makefile: 6
file content (12 lines) | stat: -rw-r--r-- 421 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
"""Triangulate arbitrary line contours in 2D.
The contours may be concave, and even contain holes."""
from vedo import Star, merge, show

# let's create two bidimensional contour lines
s1 = Star(line=True, n=9)
s2 = Star(line=True, n=5, r1=0.3, r2=0.4).x(0.12)

# merge the 2 lines and triangulate the inner region
sm = merge(s1, s2).triangulate().c('lightsalmon').lw(1)

show([(s1,s2,__doc__), sm], N=2, axes=8).close()