Here you can find the source of calculateDistance(int x1, int y1, int z1, int x2, int y2, int z2)
Parameter | Description |
---|---|
x1 | X1 |
y1 | Y1 |
z1 | Z1 |
x2 | X2 |
y2 | Y2 |
z2 | Z2 |
public static double calculateDistance(int x1, int y1, int z1, int x2, int y2, int z2)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w ww . j a va 2 s .c o m*/ * This method calculated the distance between two points in 3D space * @param x1 X1 * @param y1 Y1 * @param z1 Z1 * @param x2 X2 * @param y2 Y2 * @param z2 Z2 * @return The distance between the two points */ public static double calculateDistance(int x1, int y1, int z1, int x2, int y2, int z2) { double x_distance = x1 - x2; double y_distance = y1 - y2; double z_distance = z1 - z2; double sum = x_distance * x_distance; sum += y_distance * y_distance; sum += z_distance * z_distance; return Math.sqrt(sum); } /** * This method calculated the distance between two points in 3D space * @param a1 * @param b1 * @param a2 * @param b2 * @return */ public static double calculateDistance(int a1, int b1, int a2, int b2) { double a_distance = a1 - a2; double b_distance = b1 - b2; double sum = a_distance * a_distance; sum += b_distance * b_distance; return Math.sqrt(sum); } }