Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2D nearest neighbour search for moving points

I want do do some flocking simulation, as described here.

For this I need to search for the nearest neighbours of each of my 2D points. However, I cannot use a static data structure like a k-d tree because the points are always moving...

What's a good (easy) datastructure/library that is able to achieve this? I'm working with C++...

like image 451
Jan Rüegg Avatar asked Aug 07 '11 06:08

Jan Rüegg


People also ask

How do I find my second nearest Neighbour?

Second neighbours are at the centers of the nearest adjacent cells. Third neighbours: centers of the next adjacent cells (those which share two corners with your cell). Fourth neighbours: far corners of the nearest adjacent cells.

What is K search?

k-nearest neighbor search identifies the top k nearest neighbors to the query. This technique is commonly used in predictive analytics to estimate or classify a point based on the consensus of its neighbors.

How do I find the nearest Neighbour analysis?

The average nearest neighbor ratio is calculated as the observed average distance divided by the expected average distance (with expected average distance being based on a hypothetical random distribution with the same number of features covering the same total area).

What is nearest neighbor search explain with example?

It is an algorithmic primitive for finding all similar pairs, solving clustering problems on large datasets, closest pair problems in computational geometry, and is used in recommendation systems, spell- checkers, and more. d(pi,q) i.e. the closest point to q in the set P. define other distances too.


2 Answers

People have studied this problem. The important keyword is kinetic, when looking for work in this ares.

like image 106
carlosdc Avatar answered Sep 21 '22 12:09

carlosdc


Maybe you want to try a quadtree or a spatial index? What's the problem with a k-d tree? Basically when have the edge the flock/points you can skip checking collision with edges far away. A spatial index can be a quadtree, r-tree, kd-tree or hilbert r-tree. A better answer can be read here: Approximate, incremental nearest-neighbour algorithm for moving bodies

"That is, recursively partition the "world" into a graph with four subnodes each. The tree can then quickly check which objects are inside a particular square of the world and discard the rest. A very effective culling technique often used for improving performance of collision detection in games."

like image 26
Micromega Avatar answered Sep 25 '22 12:09

Micromega