code: private double[] calculateDirectionFactor( double dx, double dy ) {
          // direction factor, where the components are 1/length
          double[] fact = new double[9];
          for( int k = 1; k <= 8; k++ ) {
              fact[k] = 1.0 / (Math.sqrt(DIR_WITHFLOW_EXITING_INVERTED[k][0] * dy * DIR_WITHFLOW_EXITING_INVERTED[k][0] * dy
                      + DIR_WITHFLOW_EXITING_INVERTED[k][1] * DIR_WITHFLOW_EXITING_INVERTED[k][1] * dx * dx));
          }
          return fact;
      }
docs: Calculate the drainage direction factor.
  
  @param dx is the resolution of the raster map in the x direction.
  @param dy is the resolution of the raster map in the y direction.
  @return <b>fact</b> the direction factor (or 1/length) where length is the distance of the
  pixel from the central pixel.