首页 > 解决方案 > 用不同的数据结构表示三角剖分

问题描述

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 中是否有用于这些转换的库,或者我应该自己编写代码?

标签: pythongraphicsscipytriangulationdelaunay

解决方案


ipgraphNetworkX浮现在脑海中。

您可能还想查看PythonGraphApi 的一般想法部分,因为它列出了相当多的库......

老实说,我自己对图形库的经验非常有限,所以你的里程可能会有所不同......


推荐阅读