Is there some method to get a triangulation in 2D that is more ordered like Matlab Delaunay produces? Here is an example of Matlab's 2D Delaunay triangulation.
Using this code:
xPoints = np.arange(0,11,1)
yPoints = np.arange(0,11,1)
gridPoints = np.array([[x,y] for y in yPoints for x in xPoints])
tri = Delaunay(gridPoints)
plt.triplot(gridPoints[:,0],gridPoints[:,1],tri.simplices.copy())
plt.plot(gridPoints[:,0],gridPoints[:,1],'bo')
plt.title("Triangulation Visualization")
I get the triangulation below:
Notice how diagonal arcs in the Matlab result all have the same slope; but those in the scipy result are varying. Since Matlab and Scipy both use QHull internally, I presume there is some method to mimic the Matlab result.
You could try Triangulation instead of Delaunay:
import matplotlib.tri as tri
xlen = 10
ylen = 16
xPoints = np.arange(0,xlen+1,1)
yPoints = np.arange(0,ylen+1,1)
gridPoints = np.array([[[x,y] for y in yPoints] for x in xPoints])
a = [[i+j*(ylen+1),(i+1)+j*(ylen+1),i+(j+1)*(ylen+1)] for i in range(ylen) for j in range(xlen)]
triang = tri.Triangulation(gridPoints[:,:,0].flatten(), gridPoints[:,:,1].flatten(),a)
plt.triplot(triang)
plt.plot(gridPoints[:,:,0],gridPoints[:,:,1],'bo')
plt.title("Triangulation Visualization")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With