Java Distance Calculate distSquareVec3(final float[] v1, final float[] v2)

Here you can find the source of distSquareVec3(final float[] v1, final float[] v2)

Description

Return the squared distance between the given two points described vector v1 and v2.

License

Open Source License

Declaration

public static float distSquareVec3(final float[] v1, final float[] v2) 

Method Source Code

//package com.java2s;

public class Main {
    /**//  w w  w. ja v a 2 s . c o m
     * Return the squared distance between the given two points described vector v1 and v2.
     * <p>
     * When comparing the relative distance between two points it is usually sufficient to compare the squared
     * distances, thus avoiding an expensive square root operation.
     * </p>
     */
    public static float distSquareVec3(final float[] v1, final float[] v2) {
        final float dx = v1[0] - v2[0];
        final float dy = v1[1] - v2[1];
        final float dz = v1[2] - v2[2];
        return dx * dx + dy * dy + dz * dz;
    }
}

Related

  1. distSq(double x1, double y1, double z1, double x2, double y2, double z2)
  2. distSqr2(double x1, double y1, double x2, double y2)
  3. distSquared(double ax, double ay, double bx, double by)
  4. distSquared(float x0, float y0, float x1, float y1)
  5. distSquaredCartesian(double[] vec1, double[] vec2)
  6. distSymbol(int dist)
  7. distToRectNode(double[] point, double[] nodeCenter, double nodeRadius)
  8. distUndermod(double a, double b, double mod)
  9. distVector(double[] vector1, double[] vector2)