URGENT: Find pth nearest neighbour

Paul Harris paulharris at computer.org
Wed Apr 23 03:49:32 UTC 2008


Hi Ali,

You could probably do it right now via find_nearest_if() and a predicate...
off the top of my head:

the predicate could be a struct with a state variable (ie pimpl pattern so
it can be copied around, and keeps the data in a pointer)...   it will be
called with a node each time it gets closer and closer to the nearest node.

the predicate could do a distance comparison each time, and store the best
two nodes that it sees.   then it can return TRUE each time the node is
CLOSER than the SECOND node (the second-closest point), and return FALSE
each time the node is FURTHER than the second node.

i think that would work, you want a fast response so there is a possibly
half-baked idea.

see ya
Paul

On 23/04/2008, Ali - <saveez at hotmail.com> wrote:
>
>
> Hi,
>
> It seems someone asked about this feature in October last year which,
> unfortunately, has not been implemented yet. It was suggested that adding a
> new _M_find() with some modifications could be a quick way of doing this, it
> is not clear to me how this may be done.
>
> Currently I am only interested in the 1st and 2nd nearest neighbours, I
> wonder if a developer could provide a working example for this. This is
> urgent, a less-than-12-hours remedy is well appreciated.
>
> Moreover, is there any examples around for the new find() framework?
>
> -Ali
>
> _________________________________________________________________
> Be a superhero and win! Play the Iron Man Mashup Game
> http://www.ironmanmashup.co.uk
> _______________________________________________
> libkdtree-devel mailing list
> libkdtree-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/libkdtree-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/libkdtree-devel/attachments/20080423/fd41fc9f/attachment.htm 


More information about the libkdtree-devel mailing list