python 中的多面体边

Edges of polytope in python

我找遍了这个,但我找不到任何东西!我使用 pycddlib 从不等式表示中获取多胞形的顶点。但是,我不仅需要顶点,还需要边。我找不到任何包裹来获取它们;凸包库提供面或顶点列表但不提供边。

如果两个顶点都在两个平面上,则它们构成一条边。

如果库没有 return 关于平面-顶点连通性的信息,那么对于每个顶点,通过将其置于不等式中来检查它在哪个平面上。比找到共享两个平面的顶点对。

可以得到如下边:

poly = pcdd.Polyhedron(mat)

# get the adjacent vertices of each vertex
adjacencies = [list(x) for x in poly.get_input_adjacency()]

# store the edges in a matrix (giving the indices of the points)
edges = []
for i,indices in enumerate(adjacencies[:-1]):
    indices = list(filter(lambda x: x>i, indices))
    l = len(indices)
    if l>0:
        col1 = np.full((l, 1), i)
        indices = np.reshape(indices, (l, 1))
        edges.append(np.hstack((col1, indices)))
Edges = np.vstack(tuple(edges))