我有一個坐標點的串列,我想按順時針/逆時針對它們進行排序。
這是我提到的串列。
[(985,268),(112,316),(998,448),(1018,453),(1279,577),(1196,477),(1161,443),(986,0),(830,0),(983,230),(998,425),(998,255)]
這些坐標點將幫助我繪制一個物體的線段。下面是一張用于說明的圖片。正如你所看到的,我已經在這張圖片的串列中標記了所有的點。
而我的目標是對這些坐標點進行排序,以創建幾個線段。因此,我的預期結果將是如下。
逆時針方向。[(985, 268), (998, 425), (112, 316), (998, 448), (1018, 453), (1279, 577), (1196, 477), (1161, 443), (998, 255), (986, 0), (983, 230), (830, 0)]
逆時針方向。[(985,268),(830,0),(983,230),(986,0),(998,255),(1161,443),(1196,477),(1279,577),(1018,453),(998,448),(112,316),(998,425)]
points = sort_counterclockwise(point, (0,0)
plt.plot([x for x,_ in points], [y for _,y in points] )
plt.show()
points = sort_counterclockwise(point, (1000, 200)
plt.plot([x for x,_ in points], [y for _,y in points] )
plt.show()
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/310874.html
標籤:
下一篇:如何用js計算排除周末后的天數




