我已经有了一个由scipy.spatial.Delaunay()
对象三角化的矩形。我设法拉伸和弯曲它,使它看起来像一个沿着一条线切割的环。下面是一些代码,用于制作具有相同拓扑结构的东西:
from scipy.spatial import Delaunay
NR = 22
NTheta = 36
Rin = 1
Rout = 3
alphaFactor = 33/64
alpha = np.pi/alphaFactor # opening angle of wedge
u=np.linspace(pi/2, pi/2 + alpha, NTheta)
v=np.linspace(Rin, Rout, NR)
u,v=np.meshgrid(u,v)
u=u.flatten()
v=v.flatten()
#evaluate the parameterization at the flattened u and v
x=v*np.cos(u)
y=v*np.sin(u)
#define 2D points, as input data for the Delaunay triangulation of U
points2D=np.vstack([u,v]).T
xy0 = np.vstack([x,y]).T
triLattice = Delaunay(points2D) #triangulate the rectangle U
triSimplices = triLattice.simplices
plt.figure()
plt.triplot(x, y, triSimplices, linewidth=0.5)
从这个拓扑开始,我现在想把两个开放的边连接起来,形成一个封闭的环形空间(也就是说,改变拓扑结构)。如何手动将新三角形添加到现有三角剖分中?在
一个解决方案是合并间隙周围的点。以下是一种方法,通过跟踪相应点的索引:
它给出了:
也许您需要调整
alphaFactor
的定义,以便间隙具有正确的大小。在相关问题 更多 >
编程相关推荐