cheshirekow  v0.1.0
Nearest.hpp
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_DUBINS_KD_TREE_NEAREST_HPP_
28 #define MPBLOCKS_DUBINS_KD_TREE_NEAREST_HPP_
29 
30 
31 namespace mpblocks {
32 namespace dubins {
33 namespace kd_tree {
34 
35 
36 
37 
38 template <typename Scalar>
40 {
41  m_d2Best = 0;
42  m_nBest = 0;
43 }
44 
45 
46 
47 template <typename Scalar>
49 {
50  return m_nBest;
51 }
52 
53 
54 
55 
56 template <typename Scalar>
57 void Nearest<Scalar>::evaluate( const Point& q, const Point& p, Node_t* n)
58 {
59  Scalar d2 = m_dist2Fn(q,p);
60  if( d2 < m_d2Best || !m_nBest )
61  {
62  m_d2Best = d2;
63  m_nBest = n;
64  }
65 }
66 
67 
68 
69 
70 template <typename Scalar>
72 {
73  Scalar d2 = m_dist2Fn(q,r);
74  return (d2 < m_d2Best);
75 }
76 
77 
78 
79 
80 
81 
82 } // namespace kd_tree
83 } // namespace dubins
84 } // namespace mpblocks
85 
86 
87 
88 
89 
90 
91 
92 
93 #endif // NEARESTNEIGHBOR_H_
virtual bool shouldRecurse(const Point &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:71
virtual void evaluate(const Point &q, const Point &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
Eigen::Matrix< Scalar, 3, 1 > Point
Definition: Nearest.h:45