def read_data_tri(filename):
data = numpy.loadtxt(filename)
if len(data.shape) == 1:
data = numpy.array([data])
points = data[:, :2]
weights = data[:, 2]
# The reference triangle is (-1, -1), (1, -1), (-1, 1). Transform the
# points to barycentric coordinates.
points += 1.0
points *= 0.5
points = numpy.array([
points[:, 0],
points[:, 1],
1.0 - numpy.sum(points, axis=1)
]).T
return points, weights * 0.5
评论列表
文章目录