coords.Coords.closest_to_point#

Coords.closest_to_point(p, return_dist=False)#

Returns the point closest to a given point p.

Parameters#

p: array_like (3,)

Coordinates of a single point in space

return_distbool, optional

If True, also return the minimal Euclidean distance.

Returns#

int or tuple of (int, float)

If return_dist is False, returns the index of the point in the Coords that has the minimal Euclidean distance to p. Use this index with self.points() to get the coordinates. If return_dist is True, returns a tuple (index, distance).

Examples#

>>> X = Coords([[[0.,0.,0.],[3.,0.,0.],[0.,3.,0.]]])
>>> X.closest_to_point([2.,0.,0.])
1
>>> X.closest_to_point([2.,0.,0.],True)
(1, 1.0)