Java Array Normalize normSquareVec2(final float[] vec)

Here you can find the source of normSquareVec2(final float[] vec)

Description

Return the squared length of a vector, a.k.a the squared norm or squared magnitude

License

Open Source License

Declaration

public static float normSquareVec2(final float[] vec) 

Method Source Code

//package com.java2s;

public class Main {
    /**// w  w  w .java  2 s.c om
     * Return the squared length of a vector, a.k.a the squared <i>norm</i> or squared <i>magnitude</i>
     */
    public static float normSquareVec2(final float[] vec) {
        return vec[0] * vec[0] + vec[1] * vec[1];
    }

    /**
     * Return the squared length of a vector, a.k.a the squared <i>norm</i> or squared <i>magnitude</i>
     */
    public static float normSquareVec2(final float[] vec, final int offset) {
        float v = vec[0 + offset];
        final float r = v * v;
        v = vec[1 + offset];
        return r + v * v;
    }
}

Related

  1. normData(double[] data)
  2. normII(double[] b)
  3. normLat(double[] latLng)
  4. normLng(double[] latLng)
  5. normOf(float[] vector)
  6. normVector(double[] pos)