Here you can find the source of normalize(float[] vec)
public static void normalize(float[] vec)
//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; } }