cheshirekow  v0.1.0
Nearest.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef MPBLOCKS_KD_TREE_EUCLIDEAN_NEAREST_H_
28 #define MPBLOCKS_KD_TREE_EUCLIDEAN_NEAREST_H_
29 
30 
31 namespace mpblocks {
32 namespace kd_tree {
33 namespace euclidean {
34 
37 template <class Traits>
38 class Nearest :
39  public NearestSearchIface<Traits>
40 {
41  public:
42  typedef typename Traits::Format_t Format_t;
43  typedef typename Traits::Node Node_t;
44 
47 
48  typedef Eigen::Matrix<Format_t,Traits::NDim,1> Point_t;
49 
50  private:
54 
55  public:
56  virtual ~Nearest(){};
57 
58  // reset d2Best to be infinity
59  void reset( Format_t inf = std::numeric_limits<Format_t>::max() );
60 
61  // return the result
62  Node_t* result();
63 
66  virtual void evaluate(const Point_t& q, const Point_t& p, Node_t* n);
67 
71  virtual bool shouldRecurse(const Point_t& q, const HyperRect_t& r );
72 };
73 
74 
75 
76 
77 
78 
79 } // namespace euclidean
80 } // namespace kd_tree
81 } // namespace mpblocks
82 
83 
84 
85 
86 
87 
88 
89 
90 #endif // NEARESTNEIGHBOR_H_
provides euclidean distance computation
Definition: Distance.h:38
HyperRect< Traits > HyperRect_t
Definition: Nearest.h:46
Distance< Traits > Distance_t
Definition: Nearest.h:45
virtual void evaluate(const Point_t &q, const Point_t &p, Node_t *n)
calculates Euclidean distance from q to p, and if its less than the current best replaces the current...
Definition: Nearest.hpp:57
Interface for nearest node type searches.
Definition: NearestSearch.h:38
void reset(Format_t inf=std::numeric_limits< Format_t >::max())
Definition: Nearest.hpp:39
the node class must be defined in traits since it uses the CTRP, it must derive from kd_tree::Node<Tr...
Definition: Traits.h:49
provides a search algorithm for finding the nearest point in the kd tree to some query point...
Definition: Nearest.h:38
virtual bool shouldRecurse(const Point_t &q, const HyperRect_t &r)
evaluate the Euclidean distance from q to it's closest point in r and if that distance is less than t...
Definition: Nearest.hpp:72
Eigen::Matrix< Format_t, Traits::NDim, 1 > Point_t
Definition: Nearest.h:48
double Format_t
number format (i.e. double, float)
Definition: Traits.h:38
an NDim dimensional hyperrectangle, represented as a min and max extent
Definition: HyperRect.h:23