Java Array Normalize normalize(float[] vec)

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

Description

normalize

License

Open Source License

Declaration

public static void normalize(float[] vec) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static void normalize(float[] vec) {
        float a = 1.f / length(vec);
        multVector(vec, a);//ww  w . ja v  a  2  s. c o  m
    }

    public static float length(float[] vec) {
        return (float) Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
    }

    public static void multVector(float[] vec, float a) {
        vec[0] *= a;
        vec[1] *= a;
        vec[2] *= a;
    }
}

Related

  1. normalize(float[] data)
  2. normalize(float[] in)
  3. normalize(float[] in)
  4. normalize(float[] input)
  5. normalize(float[] v)
  6. normalize(float[][] vals, float min, float max)
  7. normalize(int[] a)
  8. normalize(int[] values)
  9. normalize(int[][][] data, int startX, int startY, int stopX, int stopY, double scale)