Here you can find the source of normalize(float[] v)
Parameter | Description |
---|---|
v | a parameter |
protected static float[] normalize(float[] v)
//package com.java2s; public class Main { /**//from ww w.j a v a2 s.co m * Normalize vector * * @param v * * @return float[] */ protected static float[] normalize(float[] v) { float r; r = (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); if (r == 0.0) return v; r = 1.0f / r; v[0] *= r; v[1] *= r; v[2] *= r; return v; } }