Google has a KD Tree Library written in C: Here

As far as I can tell, you insert notes into the tree using one of it's functions, and then query the tree for nearest neighbors. It returns a pointer to a new array (as far as I can tell).

Here is my goal:

I have a 3D array and I am hoping to find a way to return the index of a given point's nearest neighbor. I want to say: Here is a point: (12,23,14), now tell me the index of the point that is closest ex: "it is the 5th item in your array". However, I am not sure how to do this.

My Questions, Does anyone:

A) Know of a good well documented k dimensional nearest neighbor search library for c, or:

B) Know how to get Google's code to return the position of the nearest neighbor in an array.

有帮助吗?

解决方案

The library you linked, from my understanding does not have the n-nearest neighbour search functions implemented. I don't have any other kd-tree library in mind for C.

Implementing a simple kd-tree is not very complex and it should be a good exercise. You could for example follow http://ldots.org/kdtree/ .

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top