question: static double fourNeighborsIDW ( SpatialGrid sg , double xCoord , double yCoord , double exp ) { double xDif = ( xCoord - sg . getXmin ( ) ) % sg . getResolution ( ) ; double yDif = ( yCoord - sg . getYmin ( ) ) % sg . getResolution ( ) ; if ( xDif == 0 && yDif == 0 ) { return sg . getValue ( xCoord , yCoord ) ; } double x1 = xCoord - xDif ; double x2 = x1 + sg . getResolution ( ) ; double y1 = yCoord - yDif ; double y2 = y1 + sg . getResolution ( ) ; double d11 = Math . pow ( distance ( x1 , y1 , xCoord , yCoord ) , exp ) ; double d12 = Math . pow ( distance ( x1 , y2 , xCoord , yCoord ) , exp ) ; double d21 = Math . pow ( distance ( x2 , y1 , xCoord , yCoord ) , exp ) ; double d22 = Math . pow ( distance ( x2 , y2 , xCoord , yCoord ) , exp ) ; if ( xCoord == sg . getXmax ( ) ) { return ( sg . getValue ( x1 , y1 ) / d11 + sg . getValue ( x1 , y2 ) / d12 ) / ( 1 / d11 + 1 / d12 ) ; } if ( yCoord == sg . getYmax ( ) ) { return ( sg . getValue ( x1 , y1 ) / d11 + sg . getValue ( x2 , y1 ) / d21 ) / ( 1 / d11 + 1 / d21 ) ; } return ( sg . getValue ( x1 , y1 ) / d11 + sg . getValue ( x1 , y2 ) / d12 + sg . getValue ( x2 , y1 ) / d21 + sg . getValue ( x2 , y2 ) / d22 ) / ( 1 / d11 + 1 / d12 + 1 / d21 + 1 / d22 ) ; }
target:  Interpolates a value at the given point (xCoord, yCoord) with the inverse distance weighting with variable power of weights.  Considers only four neighboring values.