static double minDistance ( pair A , pair B , pair E ) {
  pair AB = new pair ( ) ;
  AB . F = B . F - A . F ;
  AB . S = B . S - A . S ;
  pair BE = new pair ( ) ;
  BE . F = E . F - B . F ;
  BE . S = E . S - B . S ;
  pair AE = new pair ( ) ;
  AE . F = E . F - A . F ;
  AE . S = E . S - A . S ;
  double AB_BE , AB_AE ;
  AB_BE = ( AB . F * BE . F + AB . S * BE . S ) ;
  AB_AE = ( AB . F * AE . F + AB . S * AE . S ) ;
  double reqAns = 0 ;
  if ( AB_BE > 0 ) {
    double y = E . S - B . S ;
    double x = E . F - B . F ;
    reqAns = Math . sqrt ( x * x + y * y ) ;
  }
  else if ( AB_AE < 0 ) {
    double y = E . S - A . S ;
    double x = E . F - A . F ;
    reqAns = Math . sqrt ( x * x + y * y ) ;
  }
  else {
    double x1 = AB . F ;
    double y1 = AB . S ;
    double x2 = AE . F ;
    double y2 = AE . S ;
    double mod = Math . sqrt ( x1 * x1 + y1 * y1 ) ;
    reqAns = Math . abs ( x1 * y2 - y1 * x2 ) / mod ;
  }
  return reqAns ;
}

static double minDistance ( pair A , pair B , pair E ) { pair AB = new pair ( ) ; AB . F = B . F - A . F ; AB . S = B . S - A . S ; pair BE = new pair ( ) ; BE . F = E . F - B . F ; BE . S = E . S - B . S ; pair AE = new pair ( ) ; AE . F = E . F - A . F ; AE . S = E . S - A . S ; double AB_BE , AB_AE ; AB_BE = ( AB . F * BE . F + AB . S * BE . S ) ; AB_AE = ( AB . F * AE . F + AB . S * AE . S ) ; double reqAns = 0 ; if ( AB_BE > 0 ) { double y = E . S - B . S ; double x = E . F - B . F ; reqAns = Math . sqrt ( x * x + y * y ) ; } else if ( AB_AE < 0 ) { double y = E . S - A . S ; double x = E . F - A . F ; reqAns = Math . sqrt ( x * x + y * y ) ; } else { double x1 = AB . F ; double y1 = AB . S ; double x2 = AE . F ; double y2 = AE . S ; double mod = Math . sqrt ( x1 * x1 + y1 * y1 ) ; reqAns = Math . abs ( x1 * y2 - y1 * x2 ) / mod ; } return reqAns ; }
(method_declaration (modifiers) type: (floating_point_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier)) declarator: (variable_declarator name: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (identifier) field: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier)))))))) alternative: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (identifier)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier))))) right: (identifier))))))) (return_statement (identifier))))