Java Euclidean Distance euclideanDistance(int startX, int startY, int startZ, int endX, int endY, int endZ)

Here you can find the source of euclideanDistance(int startX, int startY, int startZ, int endX, int endY, int endZ)

Description

See link below for more information about how this works http://www.policyalmanac.org/games/aStarTutorial.htm Thanks to @Adamki11s, who's source I took inspiration from on how to do this, check out his Bukkit post here: https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/

License

Open Source License

Declaration


public static double euclideanDistance(int startX, int startY,
        int startZ, int endX, int endY, int endZ) 

Method Source Code

//package com.java2s;
/* // w w  w. ja  v  a2  s  .co  m
 * Enderstone
 * Copyright (C) 2014 Sander Gielisse and Fernando van Loenhout
 *
 *     This program 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.
 *
 *     This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * 
     * See link below for more information about how this works
     * http://www.policyalmanac.org/games/aStarTutorial.htm
     * 
     * Thanks to @Adamki11s, who's source I took inspiration from on how to do this, check out his Bukkit post here:
     * https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/
     * 
     */

    public static double euclideanDistance(int startX, int startY,
            int startZ, int endX, int endY, int endZ) {
        double dx = startX - endX;
        double dy = startY - endY;
        double dz = startZ - endZ;
        return Math.sqrt((dx * dx) + (dy * dy) + (dz * dz));
    }
}

Related

  1. euclideanDistance(double[] p, double[] q)
  2. euclideanDistance(double[] vector)
  3. euclideanDistance(double[] vector1, double[] vector2)
  4. euclideanDistance(float[] points, int p1, int p2, boolean isDisp, double width, double height)
  5. euclideanDistance(int i0, int j0, int i1, int j1)
  6. euclideanDistanceNorm(float[] x, float[] y)
  7. euclideanDistanceSq2D(float x1, float y1, float x2, float y2)