Here you can find the source of distance(double xOrigin, double yOrigin, double xDestination, double yDestination)
public static double distance(double xOrigin, double yOrigin, double xDestination, double yDestination)
//package com.java2s; //License from project: Open Source License public class Main { public static double distance(double xOrigin, double yOrigin, double xDestination, double yDestination) { double offsetX = xDestination - xOrigin; double offsetY = yDestination - yOrigin; return Math.sqrt(offsetX * offsetX + offsetY * offsetY); }/*from w w w . j a va 2 s.co m*/ }