private double maxDistLevel(DBID id,int level){
  final NumberVector obj=relation.get(id);
  final double r=1.0 / (1 << (level - 1));
  double dist;
  if (t == 1.0) {
    dist=0.0;
    for (int dim=0; dim < d; dim++) {
      final double p_m_r=getDimForObject(obj,dim) % r;
      dist+=Math.max(p_m_r,r - p_m_r);
    }
  }
 else   if (t == 2.0) {
    dist=0.0;
    for (int dim=0; dim < d; dim++) {
      final double p_m_r=getDimForObject(obj,dim) % r;
      double a=Math.max(p_m_r,r - p_m_r);
      dist+=a * a;
    }
    dist=Math.sqrt(dist);
  }
 else   if (!Double.isInfinite(t)) {
    dist=0.0;
    for (int dim=0; dim < d; dim++) {
      final double p_m_r=getDimForObject(obj,dim) % r;
      dist+=Math.pow(Math.max(p_m_r,r - p_m_r),t);
    }
    dist=Math.pow(dist,1.0 / t);
  }
 else {
    dist=Double.NEGATIVE_INFINITY;
    for (int dim=0; dim < d; dim++) {
      final double p_m_r=getDimForObject(obj,dim) % r;
      dist=Math.max(dist,Math.max(p_m_r,r - p_m_r));
    }
  }
  return dist * diameter;
}

private double maxDistLevel ( DBID id , int level ) { final NumberVector obj = relation . get ( id ) ; final double r = 1.0 / ( 1 << ( level - 1 ) ) ; double dist ; if ( t == 1.0 ) { dist = 0.0 ; for ( int dim = 0 ; dim < d ; dim ++ ) { final double p_m_r = getDimForObject ( obj , dim ) % r ; dist += Math . max ( p_m_r , r - p_m_r ) ; } } else if ( t == 2.0 ) { dist = 0.0 ; for ( int dim = 0 ; dim < d ; dim ++ ) { final double p_m_r = getDimForObject ( obj , dim ) % r ; double a = Math . max ( p_m_r , r - p_m_r ) ; dist += a * a ; } dist = Math . sqrt ( dist ) ; } else if ( ! Double . isInfinite ( t ) ) { dist = 0.0 ; for ( int dim = 0 ; dim < d ; dim ++ ) { final double p_m_r = getDimForObject ( obj , dim ) % r ; dist += Math . pow ( Math . max ( p_m_r , r - p_m_r ) , t ) ; } dist = Math . pow ( dist , 1.0 / t ) ; } else { dist = Double . NEGATIVE_INFINITY ; for ( int dim = 0 ; dim < d ; dim ++ ) { final double p_m_r = getDimForObject ( obj , dim ) % r ; dist = Math . max ( dist , Math . max ( p_m_r , r - p_m_r ) ) ; } } return dist * diameter ; }
maxdist function calculate the maximal distance from vector p to the border of the corresponding r - region at the given level
