Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] How to get the index of the K-Nearest Neighbor points

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] How to get the index of the K-Nearest Neighbor points


Chronological Thread 
  • From: Johannes Otepka <>
  • To:
  • Subject: Re: [cgal-discuss] How to get the index of the K-Nearest Neighbor points
  • Date: Tue, 13 Mar 2007 11:11:05 +0100

Sophea,

With the existing code this cannot be done effeciently, since the K-Nearest neighbor object stores point copies. You have to adapt the Orthogonal_k_neighbor_search class in such a way that is stores point pointers (or point references). Not vey difficult to do.... After that the index can be computed by simple pointer arithmetic.

If you are interested, I can send my code which contains those changes and some additional <ende?lp=ende&p=/gQPUD&search=additional> optimisation <ende?lp=ende&p=/gQPUD&search=optimisation>s.
Cheers,
Johannes

Chansophea Chuon wrote:

Dear All:

Suppose that we pass a vector of points(std::vector<Point_3 <http://www.cgal.org/Manual/3.2/doc_html/cgal_manual/Kernel_d_ref/Class_Point_d.html#Cross_link_anchor_361>> points) to the (Tree tree(points.begin(), points.end()))

Then we find the K-Nearest neighbors

Neighbor_search search(tree, query, N);
// This should sort all N points by increasing distance from origin

for(Neighbor_search::iterator it = search.begin(); it != search.end(); ++it){
std::cout << it->first << " "<< std::sqrt <http://www.cgal.org/Manual/3.2/doc_html/cgal_manual/NumberTypeSupport_ref/Function_sqrt.html#Cross_link_anchor_1176>(it->second) << std::endl;
}

We get the K-Nearest neighbors points and their distances. How to get the index of the K
-Nearest neighbors in the vector effeciently? Does the Neighbor_search::iterator provide the indexes?

Best regards,

Sophea

------------------------------------------------------------------------
Don't get soaked. Take a quick peek at the forecast <http://tools.search.yahoo.com/shortcuts/?fr=oni_on_mail&#news>
with theYahoo! Search weather shortcut. <http://tools.search.yahoo.com/shortcuts/?fr=oni_on_mail&#news>






Archive powered by MHonArc 2.6.16.

Top of Page