Here you can find the source of distanceSquared(double x1, double y1, double x2, double y2)
public static double distanceSquared(double x1, double y1, double x2, double y2)
//package com.java2s; public class Main { /**/* ww w .j a va 2 s . co m*/ * Return the square of the distance between * two points, (x1, y1) and (x2, y2). */ public static double distanceSquared(double x1, double y1, double x2, double y2) { return Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2); } }