cheshirekow  v0.1.0
HyperRect.hpp
Go to the documentation of this file.
1 
9 #ifndef MPBLOCKS_KD_TREE_EUCLIDEAN_HYPERRECT_HPP_
10 #define MPBLOCKS_KD_TREE_EUCLIDEAN_HYPERRECT_HPP_
11 
12 #include <limits>
13 
14 namespace mpblocks {
15 namespace kd_tree {
16 namespace euclidean {
17 
18 
19 template < class Traits >
21 {
22  minExt.fill(0);
23  maxExt.fill(0);
24 }
25 
26 
27 
28 
29 
30 template < class Traits >
31 typename Traits::Format_t
33 {
34  Format_t dist2 = 0;
35  Format_t dist2i = 0;
36 
37  for (unsigned int i=0; i < point.rows(); i++)
38  {
39  if (point[i] < minExt[i])
40  dist2i = minExt[i] - point[i];
41  else if(point[i] > maxExt[i])
42  dist2i = maxExt[i] - point[i];
43  else
44  dist2i = 0;
45 
46  dist2i *= dist2i;
47  dist2 += dist2i;
48  }
49 
50  return dist2;
51 }
52 
53 
54 
55 template < class Traits >
56 typename Traits::Format_t
58 {
59  Format_t s = 1.0;
60  for(unsigned int i=0; i < minExt.rows(); i++)
61  s *= maxExt[i] - minExt[i];
62 
63  return s;
64 }
65 
66 
67 
68 } // namespace euclidean
69 } // namespace kd_tree
70 } // namespace mpblocks
71 
72 #endif
Format_t dist2(const Point_t &point)
find the nearest point in the hyper-rectangle to the query point and return it's distance (squared) ...
Definition: HyperRect.hpp:32
HyperRect()
initialize min and max ext to be 0,0,...
Definition: HyperRect.hpp:20
Format_t measure()
return the measure of the hypercube
Definition: HyperRect.hpp:57
double Format_t
number format (i.e. double, float)
Definition: Traits.h:38