void computePointStatistics ( Point [ ] points ) { final int length = points . length ; double v [ ] = new double [ length ] ; for ( int axis = 0 ; axis < 3 ; axis ++ ) { double maxAbs = 0 ; for ( int i = 0 ; i < length ; i ++ ) { v [ i ] = points [ i ] . coordinate [ axis ] ; maxAbs = Math . max ( maxAbs , Math . abs ( v [ i ] ) ) ; } double median = QuickSelect . select ( v , length / 2 , length ) ; switch ( axis ) { case 0 : medianPoint . x = median ; break ; case 1 : medianPoint . y = median ; break ; case 2 : medianPoint . z = median ; break ; } } for ( int i = 0 ; i < length ; i ++ ) { v [ i ] = points [ i ] . distanceSq ( medianPoint ) ; } medianDistancePoint = Math . sqrt ( QuickSelect . select ( v , length / 2 , length ) ) ; // System.out.println("Median P ="+ medianPoint); // System.out.println("Median R ="+ medianDistancePoint); // System.out.println("Scale ="+ (desiredDistancePoint / medianDistancePoint)); }
For 3D points computes the median value and variance along each dimension .