Java Distance Calculate distanceSquared(double x1, double y1, double x2, double y2)

Here you can find the source of distanceSquared(double x1, double y1, double x2, double y2)

Description

Determines the non-squared distance between two hypothetical points.

License

Open Source License

Parameter

Parameter Description
x1 The X coordinate of the first point.
y1 The Y coordinate of the first point.
x2 The X coordinate of the second point.
y2 The Y coordinate of the second point.

Return

The non-squared distance between the first and second points.

Declaration

public static double distanceSquared(double x1, double y1, double x2, double y2) 

Method Source Code

//package com.java2s;
/*/*ww w .  j  a  v  a2s .  c  o m*/
 * Copyright (C) 2014  Sina Ghaffari (sina.ghaffari@mail.utoronto.ca) & Tristan Homsi (thomsi@uwaterloo.ca)
 * 
 * This file is part of Simple2D.
    
 * Simple2D is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Simple2D 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Simple2D.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Determines the non-squared distance between two hypothetical points.
     *
     * @param x1 The X coordinate of the first point.
     * @param y1 The Y coordinate of the first point.
     * @param x2 The X coordinate of the second point.
     * @param y2 The Y coordinate of the second point.
     * @return The non-squared distance between the first and second points.
     */
    public static double distanceSquared(double x1, double y1, double x2, double y2) {
        return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
    }
}

Related

  1. distanceSq(float x0, float y0, float x1, float y1)
  2. distanceSq(int x0, int y0, int x1, int y1)
  3. distanceSqr(final float[] a, final float[] b)
  4. DistanceSquareBetweenPoints(double x1, double y1, double x2, double y2)
  5. distanceSquared(double dx, double dy)
  6. distanceSquared(double x1, double y1, double x2, double y2)
  7. distanceSquared(final double[] x, final double[] y)
  8. DistanceSquared(int x1, int z1, int x2, int z2)
  9. distanceSquared(int xa, int ya, int xb, int yb)