2011-04-08 54 views

回答

3

您應該能夠使用matplotlib.delaunay.triangulate.Triangulation計算它:

三角(X,Y) 的x,y - 的點的作爲浮標1-d陣列的座標

。 。 。

屬性:(所有應被視爲 只讀保持一致性) 的x,y - 的點作爲浮標1-d陣列的座標。

circumcenters -- (ntriangles, 2) array of floats giving the (x,y) 
    coordinates of the circumcenters of each triangle (indexed by a triangle_id). 

從的matplotlib的例子之一改編(有可能是一個更清潔的方式來做到這一點,但它應該工作):

import matplotlib.pyplot as plt 
import matplotlib.delaunay 
import matplotlib.tri as tri 
import numpy as np 
import math 

# Creating a Triangulation without specifying the triangles results in the 
# Delaunay triangulation of the points. 

# First create the x and y coordinates of the points. 
n_angles = 36 
n_radii = 8 
min_radius = 0.25 
radii = np.linspace(min_radius, 0.95, n_radii) 

angles = np.linspace(0, 2*math.pi, n_angles, endpoint=False) 
angles = np.repeat(angles[...,np.newaxis], n_radii, axis=1) 
angles[:,1::2] += math.pi/n_angles 

x = (radii*np.cos(angles)).flatten() 
y = (radii*np.sin(angles)).flatten() 

tt = matplotlib.delaunay.triangulate.Triangulation(x,y) 
triang = tri.Triangulation(x, y) 

# Plot the triangulation. 
plt.figure() 
plt.gca().set_aspect('equal') 
plt.triplot(triang, 'bo-') 

plt.plot(tt.circumcenters[:,0],tt.circumcenters[:,1],'r.') 
plt.show() 
+0

不幸的是,外心屬性已在過去刪除版本的Matplotlib。 – TommasoF 2017-09-19 07:11:35

相關問題