closest_points_in_cloud_numpy

compas.geometry.closest_points_in_cloud_numpy(points, cloud, threshold=10000000, distances=True, num_nbrs=1)[source]

Find the closest points in a point cloud to a set of sample points.

Parameters:
pointsarray_like [n x 3]

The sample points.

cloudarray_like [n x 3]

The cloud points to compare to.

thresholdfloat, optional

Only points within this distance are checked.

distancesbool, optional

If True, return the distance matrix in addition to the indices of the closest points.

num_nbrsint, optional

The number of nearest neighbors to include in the result.

Returns:
list or tuple[list, array]

If distances is False, indices of the closest points in the cloud per point in points. If distances is True, indices of the closest points in the cloud per point in points and distances between points and closest points in cloud (n x n).

Notes

Items in cloud further from items in points than threshold return zero distance and will affect the indices returned if not set suitably high.

Examples

>>> from numpy import allclose
>>> points = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]
>>> cloud = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]
>>> cp = closest_points_in_cloud_numpy(points, cloud, distances=True)
>>> allclose(cp[1], [[0, 1, 1.4142, 1], [1, 0, 1, 1.4142], [1.4142, 1, 0, 1], [1, 1.4142, 1, 0]])
True