public static float pointRectDistanceSq ( IRectangle r , IPoint p ) { Point p2 = closestInteriorPoint ( r , p ) ; return Points . distanceSq ( p . x ( ) , p . y ( ) , p2 . x , p2 . y ) ; }
Returns the squared Euclidean distance between the given point and the nearest point inside the bounds of the given rectangle . If the supplied point is inside the rectangle the distance will be zero .