【发布时间】:2021-09-26 09:53:02
【问题描述】:
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Delaunay
points = np.array([[0.2, 0], [0.1, 1.1], [0.6, 0.1], [1, 0.5], [0.6,0.9], [0.4,0.4]])
tri = Delaunay(points)
#plot
plt.triplot(points[:,0], points[:,1], tri.simplices)
plt.plot(points[:,0], points[:,1], 'o')
plt.show()
print(tri.points)
"""
[[0.2 0. ]
[0. 1.1]
[0.6 0. ]
[1. 1. ]
[0.2 0.8]
[0.4 0.4]]
"""
print(tri.simplices)
"""
[[0 5 1]
[5 4 1]
[4 5 3]
[5 2 3]
[2 5 0]]
"""
这是点数组的 delaunay 三角剖分。我有点(tri.points)和三角形(tri.simplices)数组作为输出。我需要将这些转换为半边数据结构、翼边数据结构、角表数据结构和四边数据结构以用于不同的表示,并选择哪一个存储空间更少。在 Python 中是否有用于这些转换的库,还是我应该自己编写代码?
【问题讨论】:
-
对不起我的五分钱,但如果您考虑内存优化。也许这个库github.com/nschloe/meshio 带来了更多的想法。
-
你能提供正式的答案吗?这样我才能接受。 @ivan-usalko
标签: python graphics scipy triangulation delaunay