答案 0 :(得分:6)
Python解决方案:
def split(start, end, segments):
x_delta = (end[0] - start[0]) / float(segments)
y_delta = (end[1] - start[1]) / float(segments)
points = []
for i in range(1, segments):
points.append([start[0] + i * x_delta, start[1] + i * y_delta])
return [start] + points + [end]
print split([-10, 20], [20, 75], 5)
输出:
[[-10, 20], [-4.0, 31.0], [2.0, 42.0], [8.0, 53.0], [14.0, 64.0], [20, 75]]