public static double dist ( double x1 , double x2 , double y1 , double y2 , double x , double y ) {
  if ( x1 == x2 ) {
    return Math . abs ( x - x1 ) ;
  }
  else if ( y1 == y2 ) {
    return Math . abs ( y - y1 ) ;
  }
  else {
    double a = ( y1 - y2 ) / ( x1 - x2 ) ;
    double b = y1 - a * x1 ;
    return Math . abs ( y - a * x - b ) / Math . sqrt ( 1 + a * a ) ;
  }
}

public static double dist ( double x1 , double x2 , double y1 , double y2 , double x , double y ) { if ( x1 == x2 ) { return Math . abs ( x - x1 ) ; } else if ( y1 == y2 ) { return Math . abs ( y - y1 ) ; } else { double a = ( y1 - y2 ) / ( x1 - x2 ) ; double b = y1 - a * x1 ; return Math . abs ( y - a * x - b ) / Math . sqrt ( 1 + a * a ) ; } }
(method_declaration (modifiers) type: (floating_point_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (floating_point_type) name: (identifier)) (formal_parameter type: (floating_point_type) name: (identifier)) (formal_parameter type: (floating_point_type) name: (identifier)) (formal_parameter type: (floating_point_type) name: (identifier)) (formal_parameter type: (floating_point_type) name: (identifier)) (formal_parameter type: (floating_point_type) name: (identifier))) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (return_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))) alternative: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))))) (return_statement (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (decimal_integer_literal) right: (binary_expression left: (identifier) right: (identifier))))))))))))