Here you can find the source of distSquared(float x0, float y0, float x1, float y1)
Parameter | Description |
---|---|
x0 | x-coordinate of first point |
y0 | y-coordinate of first point |
x1 | x-coordinate of second point |
y1 | y-coordinate of second point |
public static float distSquared(float x0, float y0, float x1, float y1)
//package com.java2s; /*//from ww w .j a va 2 s. c o m * Copyright (c) 2011, Paul Hertz This library is free software; you can * redistribute it and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either version * 3.0 of the License, or (at your option) any later version. * http://www.gnu.org/licenses/lgpl.html This library is distributed in * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See * the GNU Lesser General Public License for more details. You should have * received a copy of the GNU Lesser General Public License along with this * library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, * Fifth Floor, Boston, MA 02110-1301, USA * * @author ##author## * @modified ##date## * @version ##version## * */ public class Main { /** * finds squared distance between two points * @param x0 x-coordinate of first point * @param y0 y-coordinate of first point * @param x1 x-coordinate of second point * @param y1 y-coordinate of second point * @return squared distance between points */ public static float distSquared(float x0, float y0, float x1, float y1) { return (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0); } /** * finds squared distance between two points * @param x0 x-coordinate of first point * @param y0 y-coordinate of first point * @param x1 x-coordinate of second point * @param y1 y-coordinate of second point * @return squared distance between points */ public static double distSquared(double x0, double y0, double x1, double y1) { return (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0); } }