简体   繁体   中英

Using Google's C KD Tree Library

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/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM