Here you can find the source of distance(int x1, int y1, int x2, int y2)
static int distance(int x1, int y1, int x2, int y2)
//package com.java2s; //License from project: LGPL public class Main { static int distance(int x1, int y1, int x2, int y2) { int x = x1 - x2; int y = y1 - y2; double d = Math.sqrt(x * x + y * y); return (int) Math.round(d); }/*from w w w . jav a2 s . com*/ }