Skip to main content
`Ctrl`+`K`

# PetscKDTreeQueryPointsNearestNeighbor

find the nearest neighbor in a `PetscKDTree`

## Synopsis

    PetscErrorCode PetscKDTreeQueryPointsNearestNeighbor(PetscKDTree tree, PetscCount num_points, const PetscReal points[], PetscReal tolerance, PetscCount indices[], PetscReal distances[])

Not Collective, No Fortran Support

## Input Parameters

- tree - tree to query

- num_points - number of points to query

- points - array of the coordinates, in point-major order

- tolerance - tolerance for nearest neighbor

## Output Parameters

- indices - indices of the nearest neighbor to the query point

- distances - distance between the queried point and the nearest neighbor

## Notes

When traversing the tree, if a point has been found to be closer than the `tolerance`, the function short circuits and doesn’t check for any closer points.

The `indices` and `distances` arrays should be at least of size `num_points`.

## See Also

`PetscKDTree`, `PetscKDTreeCreate()`

## Level

advanced

## Location

src/vec/is/utils/kdtree.c

Index of all IS routines
Table of Contents for all manual pages
Index of all manual pages