Python:圆柱体(或任何周期曲面)的Delaunay三角剖分

Python:圆柱体(或任何周期曲面)的Delaunay三角剖分,python,scipy,triangulation,delaunay,Python,Scipy,Triangulation,Delaunay,一年前,我问过如何在平面上正确地三角化一个周期性的形状:环形空间() 现在,我想将其扩展到对圆柱体(或一般来说,任何周期曲面)进行三角剖分。我尝试对2D代码进行简单的扩展: from scipy.spatial import Delaunay NZ = 14 NTheta = 14 R = 1 #radius of cylinder L = 3 #length of cylinder #define base rectangle (u,v) u=np.linspace(0, 2*np.p

一年前,我问过如何在平面上正确地三角化一个周期性的形状:环形空间()

现在,我想将其扩展到对圆柱体(或一般来说,任何周期曲面)进行三角剖分。我尝试对2D代码进行简单的扩展:

from scipy.spatial import Delaunay
NZ = 14
NTheta = 14

R = 1 #radius of cylinder 
L = 3 #length of cylinder 

#define base rectangle (u,v)
u=np.linspace(0, 2*np.pi, NTheta) #periodic direction
v=np.linspace(0, L, NZ)
# u=u[:-1] #leave out one point
u,v=np.meshgrid(u,v)
u=u.flatten()
v=v.flatten()

#evaluate the parameterization at the flattened u and v
x=R*np.cos(u)
y=R*np.sin(u)
z=v

#define 2D points, as input data for the Delaunay triangulation of U
points2D=np.vstack([u,v]).T
tri = Delaunay(points2D, incremental=True)#triangulate the rectangle U
triSimplices = tri.simplices

xyz0 = np.vstack([x,y,z]).T
我通过参数化创建一个圆柱体,并通过基本域(矩形)的
scipy.spatial.Delaunay()
获得三角剖分。显然,这种三角剖分不知道周期性。我可以通过移动最后一行并绘制以下图来清楚地看到这一点:

为了纠正这一点,我尝试了2D解决方案的一个简单扩展——在3D中添加一个额外的点,重新三角化并删除不需要的简化

Tri1 = Delaunay(points2D) #triangulate the rectangle U
Tri2 = Delaunay(xyz0)

## we add a central (0,0,L/2) point to xy0 to fill it up with triangles
last_pt = xyz0.shape[0]
xy1 = np.vstack((xyz0,(0,0,L/2)))  # add ctr point
Tri3 = Delaunay(xyz1)
print(Tri3.points.shape, Tri3.simplices.shape)
print(Tri1.points.shape, Tri1.simplices.shape)
print(Tri2.points.shape, Tri2.simplices.shape)

## remove the simplices that contain the central point
mask = ~(Tri3.simplices==last_pt).any(axis=1)
triSimplices = Tri3.simplices[mask,:]
然而,将2D代码扩展到3D似乎有一个大问题——3D中的三角剖分给出的是四面体,而不是三角形!此外,它似乎对中心点的选择更为敏感。简言之,我被困住了


那么,对这样一个周期性的曲面进行三角剖分的正确方法是什么?

对于一个打开或关闭的圆柱体,您期望的输出是什么?您知道为matplotlib实现Delaunay三角剖分的方法吗?一个使用示例。@jlandercy我正在寻找一个封闭的圆柱体。是的,我知道matplotlib的方法,但我看不出有什么不同,除非我特别要求它这样做。初始三角测量有什么问题?@lrineau它没有反映曲面是周期性的事实。三角剖分是连续曲面的离散表示,因此它也应反映任何周期性。我怎样才能做到这一点?