Here you can find the source of distance(final double x1, final double y1, final double x2, final double y2)
public static Double distance(final double x1, final double y1, final double x2, final double y2)
//package com.java2s; //License from project: Open Source License public class Main { public static Double distance(final double x1, final double y1, final double x2, final double y2) { final double dx = Math.max(x1, x2) - Math.min(x1, x2); final double dy = Math.max(y1, y2) - Math.min(y1, y2); return Math.sqrt(dx * dx + dy * dy); }// w ww . ja v a 2 s .c o m }