public static double getDistance ( double x1 , double y1 , double x2 , double y2 , int w2 , int h2 ) { final double maxX = x2 + w2 ; final double maxY = y2 + h2 ; double min = getDistance ( x1 , y1 , x2 , y2 ) ; for ( double x = x2 ; Double . compare ( x , maxX ) <= 0 ; x ++ ) { for ( double y = y2 ; Double . compare ( y , maxY ) <= 0 ; y ++ ) { final double dist = getDistance ( x1 , y1 , x , y ) ; if ( dist < min ) { min = dist ; } } } return min ; }
Get distance from point to area .