I have a numpy array of verticesshape (N, 3) containing N vertices of a spherical polygon in 3D, i.e. all these points lie on the surface of the sphere. The center and radius of the sphere are known (for example, take a unit sphere). I would like to build a spherical polygon bounded by these vertices. (Mathematically speaking, I want to build a spherically convex hull generated by these vertices).
How to do this using matplotlib? I tried Poly3DCollection, but it only calls the Euclidean polygon. I managed to build an entire unit sphere using the plot_surfacefollowing:
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = np.outer(np.cos(u), np.sin(v))
y = np.outer(np.sin(u), np.sin(v))
z = np.outer(np.ones(np.size(u)), np.cos(v))
ax.plot_surface(x, y, z, rstride=5, cstride=5, color='y', alpha=0.1)
I suggest that you can manually calculate which points to remove from x, y, z, and then use plot_surfaceto build the polygon. Will this be the right way to use, matplotlibor does it have another module that I could use directly?
If there is matplotlibno convenient way to do this, can you recommend any other library that does this?
source
share