就是已知点和点集,得到集合中距离目标点最近的一个点的问题
import numpy as np
set = [np.array([1,1]) , np.array([10,1]) , np.array([1,0])]
point = np.array([-1,0])
dist = lambda x: np.linalg.norm(x - point)
match = min(set, key = dist)
print(set.index(match))
就是已知点和点集,得到集合中距离目标点最近的一个点的问题
import numpy as np
set = [np.array([1,1]) , np.array([10,1]) , np.array([1,0])]
point = np.array([-1,0])
dist = lambda x: np.linalg.norm(x - point)
match = min(set, key = dist)
print(set.index(match))