Low-level function that computes distances to the nth nearest individual.
For each focal point, finds the closest point belonging to the nth nearest
individual (ranked by minimum distance). Called by calculate_nnd() for
each time point.
Arguments
- x
Numeric vector of x coordinates.
- y
Numeric vector of y coordinates.
- z
Numeric vector of z coordinates, or NULL for 2D data.
- individual
Factor or vector identifying which individual each point belongs to.
- keypoint
Factor or vector identifying keypoint labels, or NULL if no keypoints.
- n
Which individual to find (1 = nearest, 2 = second nearest, etc.).
- keypoint_neighbour
Character vector of keypoint(s) to consider as valid neighbours, or NULL to consider all.
Value
A tibble with columns:
nnd_individual: individual ID of the n-th nearest individualnnd_keypoint: keypoint of the closest point on that individual (only ifkeypointis not NULL)nnd_distance: distance to the closest point on the n-th nearest individual
See also
calculate_nnd() for the user-facing aniframe function