findNearest

fun findNearest(query: T, includeQuery: Boolean = false): T?(source)

Finds the nearest neighbor to the given query within the KD-Tree.

This method searches the KD-Tree to identify the closest item to the provided query point, based on the spatial arrangement of the tree and the dimensions defined in its construction.

Return

The item in the KD-Tree that is the closest to the query point, or null if the tree is empty.

Parameters

query

The query point for which the nearest neighbor is to be found.

includeQuery

If true, the query point itself can be returned as the nearest neighbor, otherwise, it is excluded from the results. Default is false.