27 #ifndef MPBLOCKS_KD_TREE_R2_S1_DISTANCE_HPP_
28 #define MPBLOCKS_KD_TREE_R2_S1_DISTANCE_HPP_
36 template <
class Traits>
43 template <
class Traits>
50 template <
class Traits>
61 template <
class Traits>
69 pb_wrap[2] = m_max + (pb[2] - m_min);
76 + m_weight * diff_a[2] * diff_a[2];
80 + m_weight * diff_b[2] * diff_b[2];
82 return std::min( d2a,d2b );
85 template <
class Traits>
92 for (
unsigned int i=0; i < 2; i++)
95 dist2i = h.
minExt[i] - p[i];
96 else if(p[i] > h.
maxExt[i])
97 dist2i = h.
maxExt[i] - p[i];
101 dist2 += dist2i * dist2i;
108 dist2i = h.
minExt[2] - p[2];
109 dist2w = (m_max + p[2] - m_min ) - h.
maxExt[2];
111 if( dist2w < dist2i )
114 dist2 += m_weight * dist2i * dist2i;
116 else if( p[2] > h.
maxExt[2] )
118 dist2i = p[2] - h.
maxExt[2];
119 dist2w = (m_max + h.
minExt[2] - m_min) - p[2];
121 if( dist2w < dist2i )
124 dist2 += m_weight * dist2i * dist2i;
138 #endif // DEFAULTDISTANCE_H_
Point_t maxExt
maximum extent of hyper-rectangle
Traits::Format_t Format_t
Eigen::Matrix< Format_t, Traits::NDim, 1 > Point_t
void configure(Format_t min, Format_t max, Format_t weight)
double Format_t
number format (i.e. double, float)
Format_t operator()(const Point_t &pa, const Point_t &pb)
return the r2_s1 distance between two points
Point_t minExt
minimum extent of hyper-rectangle
an NDim dimensional hyperrectangle, represented as a min and max extent