Here you can find the source of distance(double x1, double y1, double x2, double y2)
public static double distance(double x1, double y1, double x2, double y2)
//package com.java2s; public class Main { public static double distance(double x1, double y1, double x2, double y2) { return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }/*from ww w . j a v a2 s .c o m*/ }