I want to build a function that takes in a set of Cartesian coordinates in 3D (as a numpy array), and then assuming the coordinates represent the vertices of a convex polyhedron, return a graph in adjacency matrix form that represents the polyhedron. For example, on a cube, I want to input the 8 vertices as Cartesian coordinates, e.g.
numpy.array([
[1, 1, 1],
[1, 1, -1],
[1, -1, 1],
[-1, 1, 1],
[1, -1, -1],
[-1, 1, -1],
[-1, -1, 1],
[-1, -1, -1]
])
and then get a graph on 8 vertices where every edge of the cube is an edge in the graph.
I have made two attempts:
- Connecting edges if the distance between the vertices is sufficiently small, under some threshold I set by hand. Although this works for the cube, what I am actually interested in is the graph of more complicated solids, like the platonic or Archimedean solids as graphs. In this case, the algorithm is really hard to make work since the cutoff is ad-hoc and often cuts off lots of actual edges or makes up imaginary ones. This is a no-go.
- Building a convex hull from the points, using
scipy.spatial
‘sConvexHull
class. This almost works, except that since the hull is built from simplices, it includes extra “diagonal” edges of the simplex that I cannot figure out how to get rid of. See image below. I found in another old post where they mention using thepycddlib
library that appears to solve this problem. However, after a couple of hours I cannot for the life of me install the package.pip
fails to install it due to an error inclang
linker erroring out during the build. I followed all the instructions to try to install it in other ways, but none of them successfully installed. I’m hoping there is a simpler way to just accomplish what I am looking for, but if there really is not, then I would really appreciate help in installing this library. I am on macOS Sonoma 14.5, running Python 3.11.5.
See image, my attempt on a cube
bobross1709 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.