从无序的Python坐标列表中绘制形状

时间:2018-09-30 17:45:12

标签: python python-3.x list

The list of coordinates plotted

是否有任何算法/函数可以获得这样的结果? 我不能使用凸包算法,因为不会绘制中心的矩形

Result

如果这有帮助,坐标可以是元组列表或包含整个图片的矩阵的索引


更新

External shape only using TSP algorithm

计算时间:4.14 s

点数:140

1 个答案:

答案 0 :(得分:0)

import turtle as t

points = [(0, 0), (0, 9), (9, 9), (9, 0), (0, 0)]

for p in points:
  print(p)
  x, y = p
  t.goto(x, y)

此代码迭代 points 列表中的点。 Turtle 前往我在 points 列表中声明的每个点。 此代码构成一个正方形。

相关问题