【发布时间】:2026-02-15 17:50:02
【问题描述】:
基本上,我有一个从 csv 文件中读取的 x、y、z 坐标列表,该文件形成一个粗略的圆圈,并且没有按顺序 [[82.41657257, 0.863095999, -5400.0], [82.4160614, 0.0, -5400.0], [82.41255188, -0.863053977, -5400.0], [82.40731812, 1.726186991, -5400.0],......。我有圆心,但无法弄清楚如何对点进行排序。有没有办法将这些点按逻辑顺序(顺时针)排序?
import csv
coorinput=[]
#open and read file
with open("test.csv","rb") as readfile:
reader = csv.reader(readfile, dialect = 'excel',skipinitialspace = True)
for row in reader:
coorinput.append(map(float, row))
#call sort function here
【问题讨论】:
-
你提前知道圆圈所在的平面吗?
-
我不完全理解你的意思抱歉,暂时忽略 z 坐标,所以如果有帮助,它将是 2D,顺便说一下,我也在使用 python
-
啊,是的。这就是我要问的。
-
我认为使用unit circle 可能是一个正确方向的提示。
-
是的,我只需要能够将坐标 x,y 排序为顺时针/逆时针顺序
标签: python sorting coordinates geometry