1

I was trying to implement a cuboid and expressed it by triangle mesh. It is easy to implement a surface of a cuboid so that I wanted to try to implement the cuboid by creating six surfaces and merge them together. However, when I tried to draw a mesh surface that is vertical to the ground there is an error I can not understand:

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

x = np.random.rand(20)
y = [0] * 20
z =np.random.rand(20)

ax.plot_trisurf(x, y, z)
plt.show()


RuntimeError: Error in qhull Delaunay triangulation calculation: singular input data (exitcode=2); use python verbose option (-v) to see original qhull error.

If I switch the value of y and z it can work properly and draw a surface which is parallel to the ground.

wxxxx
  • 11
  • 1

1 Answers1

1

The call to the plot_trisurf(x, y, z) function computes a 2D Delaunay triangulation from the x, y parameters and sets the z coordinate of the triangles to the corresponding z parameter. This may be a bit misleading since you pass three coordinate arrays x, y, z and therefore might expect them to be considered in the same way, which they are not.

The reason your code crashes is that your x, y input data is in a degenerate configuration - all the x,y points are on the line y=0. This causes the underlying triangulation computation to fail - see my previous answers here and here for further explanation.

Iddo Hanniel
  • 1,636
  • 10
  • 18