34 #if defined(SeparableMetricHelper_RECURSES)
35 #error Recursive header files inclusion detected in SeparableMetricHelper.h
36 #else // defined(SeparableMetricHelper_RECURSES)
38 #define SeparableMetricHelper_RECURSES
40 #if !defined SeparableMetricHelper_h
42 #define SeparableMetricHelper_h
48 #include "DGtal/base/Common.h"
49 #include "DGtal/kernel/NumberTraits.h"
50 #include "DGtal/kernel/CBoundedInteger.h"
51 #include "DGtal/base/BasicFunctors.h"
74 template <
typename TPo
int,
typename TInternalValue, DGtal::u
int32_t tp>
136 return hi - std::pow(
abs((
double )pos - ci) , (
double)p);
150 return (
InternalValue ) std::pow ( (
double)pos, (
double)p );
168 ASSERT(
false &&
"Not-Yet-Implemented");
185 ASSERT(
false &&
"Not-Yet-Implemented");
205 const Point &second)
const
210 for(
typename Point::Dimension i=0; i < Point::dimension; i++)
212 a +=
power(
abs (origin[i] - first[i]));
213 b +=
power(
abs (origin[i] - second[i]));
248 ASSERT( (nu + (
InternalValue) std::pow( (
double)
abs( udim - lower), (
double) p)) <=
260 if ( nuUpdated < nvUpdated)
288 const Point &startingPoint,
289 const Point &endPoint,
290 const typename Point::UnsignedComponent dim)
const
294 Abscissa lower = startingPoint[dim];
302 for(
Dimension i = 0 ; i < Point::dimension ; i++)
305 nu += (
InternalValue ) std::pow ( (
double)
abs(u[i] - startingPoint[i] ) , (double)p);
306 nv += (
InternalValue ) std::pow ( (
double)
abs(v[i] - startingPoint[i] ) , (double)p);
307 nw += (
InternalValue ) std::pow ( (
double)
abs(w[i] - startingPoint[i] ) , (double)p);
314 if ((nv + (
InternalValue) std::pow( (
double)
abs( v[dim] - lower), (
double) p)) >
320 if ((nu + (
InternalValue) std::pow( (
double)
abs( u[dim] - lower), (
double) p)) >
330 trace.
info() <<
"Midpoint (u,v) ="<< uv<<
" Midpoint (v,w) ="<<vw<<std::endl;
351 template <
typename TPo
int,
typename TInternalValue>
369 return ( pos - ci ) * ( pos - ci ) + hi;
376 return hi - ( pos - ci ) * ( pos - ci ) ;
383 if ( ( ( j*j - i*i ) + hj - hi ) / ( 2* ( j - i ) ) >= 0)
384 return (
Abscissa)( ( j*j - i*i ) + hj - hi ) / ( 2* ( j - i ) );
386 return (
Abscissa)( ( j*j - i*i ) + hj - hi ) / ( 2* ( j - i ) ) -1;
393 return ( ( i*i -j*j ) + hj - hi ) / ( 2* ( i - j ) );
405 const Point &second)
const
410 for(
typename Point::Dimension i=0; i < Point::dimension; i++)
412 a += (origin[i] - first[i])*(origin[i] - first[i]);
413 b += (origin[i] - second[i])*(origin[i] - second[i]);
441 const Point &startingPoint,
443 const typename Point::UnsignedComponent dim)
const
455 for(
Dimension i = 0 ; i < Point::dimension ; i++)
458 d2_u += (u[i] - startingPoint[i] ) *(u[i] - startingPoint[i] );
459 d2_v += (v[i] - startingPoint[i] ) *(v[i] - startingPoint[i] );
460 d2_w += (w[i] - startingPoint[i] ) *(w[i] - startingPoint[i] );
463 return (c * d2_v - b*d2_u - a*d2_w - a*b*c) > 0 ;
472 template <
typename TPo
int,
typename TInternalValue>
484 return (
double ) aInternalValue;
491 return (
InternalValue ) ( ((
long int) pos - ci)>=0 ? ((
long int) pos - ci) : - ((
long int) pos - ci) ) + hi;
505 if (hj >= hi + j - i)
509 return (
int)((hj - hi + j + i) / 2);
515 if (hj <= hi - j + i)
519 return (hi + i - hj + j ) / 2;
533 const Point &second)
const
536 b=(origin-second).norm(Point::L_1);
564 const Point &startingPoint,
565 const Point &endPoint,
566 const typename Point::UnsignedComponent dim)
const
568 ASSERT(
false &&
"Not-Yet-Implemented");
580 template <
typename TPo
int,
typename TInternalValue>
591 return (
double ) aInternalValue;
598 max( (
Abscissa) (((
long int)pos - ci) >= 0 ? ((
long int)pos - ci) :
599 -((
long int)pos - ci)), (
Abscissa) hi);
606 ASSERT(
false &&
"Not-Implemented");
622 ASSERT(
false &&
"Not-Implemented");
637 const Point &second)
const
640 b=(origin-second).norm(Point::L_infty);
668 const Point &startingPoint,
669 const Point &endPoint,
670 const typename Point::UnsignedComponent dim)
const
672 ASSERT(
false &&
"Not-Yet-Implemented");
683 #endif // !defined SeparableMetricHelper_h
685 #undef SeparableMetricHelper_RECURSES
686 #endif // else defined(SeparableMetricHelper_RECURSES)