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_R2_S1_NEAREST_H_
28 #define MPBLOCKS_KD_TREE_R2_S1_NEAREST_H_
29 
30 
31 namespace mpblocks {
32 namespace kd_tree {
33 namespace r2_s1 {
34 
35 
36 template <class Traits>
37 class Nearest :
38  public NearestSearchIface<Traits>
39 {
40  public:
41  typedef typename Traits::Format_t Format_t;
42  typedef typename Traits::Node Node_t;
43 
46 
47  typedef Eigen::Matrix<Format_t,Traits::NDim,1> Point_t;
48 
49  private:
53 
54  public:
55  virtual ~Nearest(){};
56 
58  Distance_t& distFn(){ return m_dist2Fn; }
59 
60  // reset d2Best to be infinity
61  void reset( Format_t inf = std::numeric_limits<Format_t>::max() );
62 
63  // return the result
64  Node_t* result();
65 
68  virtual void evaluate(const Point_t& q, const Point_t& p, Node_t* n);
69 
73  virtual bool shouldRecurse(const Point_t& q, const HyperRect_t& r );
74 };
75 
76 
77 
78 
79 
80 
81 } // namespace r2_s1
82 } // namespace kd_tree
83 } // namespace mpblocks
84 
85 
86 
87 
88 
89 
90 
91 
92 #endif // NEARESTNEIGHBOR_H_
Distance_t & distFn()
expose distance function
Definition: Nearest.h:58
void reset(Format_t inf=std::numeric_limits< Format_t >::max())
Definition: Nearest.hpp:39
Eigen::Matrix< Format_t, Traits::NDim, 1 > Point_t
Definition: Nearest.h:47
HyperRect< Traits > HyperRect_t
Definition: Nearest.h:45
an NDim dimensional hyperrectangle, represented as a min and max extent
Definition: HyperRect.h:23
Interface for nearest node type searches.
Definition: NearestSearch.h:38
Traits::Format_t Format_t
Definition: Nearest.h:41
provides r2_s1 distance computation
Definition: Distance.h:38
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
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
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
double Format_t
number format (i.e. double, float)
Definition: Traits.h:38
Distance< Traits > Distance_t
Definition: Nearest.h:44