Java Vector Vector2fNormalize(float[] a, float[] dest)

Here you can find the source of Vector2fNormalize(float[] a, float[] dest)

Description

Vectorf Normalize

License

Open Source License

Declaration

public static void Vector2fNormalize(float[] a, float[] dest) 

Method Source Code

//package com.java2s;
/*/* w  w  w.  ja  v a2 s  .  c o  m*/
 *    leola-live 
 *  see license.txt
 */

public class Main {
    /**
     * Float index for the X component
     */
    public static final int X = 0;
    /**
     * Float index for the Y component
     */
    public static final int Y = 1;

    public static void Vector2fNormalize(float[] a, float[] dest) {
        float fLen = (float) Math.sqrt((a[X] * a[X] + a[Y] * a[Y]));
        if (fLen == 0)
            return;

        fLen = 1.0f / fLen;
        dest[X] = a[X] * fLen;
        dest[Y] = a[Y] * fLen;
    }
}

Related

  1. shiftIndicies(List list, int[] indicies, int shiftVector)
  2. vector(final float[] p2, final float[] p1)
  3. Vector2fMult(float[] a, float[] b, float[] dest)
  4. Vector2fNegate(float[] a, float[] dest)
  5. Vector2fNew()
  6. vector2string(int[] vector)
  7. vector_dot(double[] vec1, double[] vec2)
  8. vector_norm(double[] vec)
  9. vector_sum(double[] v, double[] w)