Return all the Agents in this KDTree that are within d distance
of the given Point or Agent pt, optionally restricted to agents that
pass filterFn.
Returns the Agent in this KDTree that is closest spatially to the given
Point or Agent pt, optionally restricted to agents that pass filterFn.
When pt is an Agent, its cached __subtree reference is used directly
instead of traversing from the root, avoiding an O(log n) traversal and a
potential out-of-bounds error. The search expands outward until a
qualifying candidate is found, then widens to all subtrees within that
distance to guarantee the true nearest filtered neighbor is returned.
Distance values are computed once per candidate and cached to avoid
redundant calculations during sorting.
The nearest qualifying agent.
Rebalance the KDTree (if it has been marked as needing updating). Optionally pass the agents that belong to this tree (relevant for trees of higher depth than the top level).
Since
0.3.5