Here you can find the source of distance2(float x, float y, float x1, float y1)
public static float distance2(float x, float y, float x1, float y1)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w ww. java 2s.co m*/ * Return the distance squared between two points. */ public static float distance2(float x, float y, float x1, float y1) { x = (float) Math.pow(x - x1, 2); y = (float) Math.pow(y - y1, 2); return (x + y); } public static float distance2(float[] p1, float x, float y) { return distance2(p1[0], p1[1], x, y); } }