I have the following array in Python:
points_list = [point0, point1, point2]
where each of points_list
is of the type:
class point:
__init__(self, coord, value):
self.coord = numpy.array(coord)
self.value = value
# etc...
And a function:
def distance(x,y):
return numpy.linalg.norm(x.coord - y.coord)
And I have a point point_a
defined elsewhere. Now I want to find the point in points_list
that's closest to point_a
.
Other than a loop, what's the best way to do this in Python?