Here you can find the source of normalize(float p[])
public static float normalize(float p[])
//package com.java2s; /*// w w w . j a v a 2s . c o m * @(#)gl_util.java 0.3 06/11/20 * * jGL 3-D graphics library for Java * Copyright (c) 1999-2006 Robin Bing-Yu Chen (robin@ntu.edu.tw) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or any later version. the GNU Lesser * General Public License should be included with this distribution * in the file LICENSE. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ public class Main { public static float normalize(float p[]) { float w = (float) Math.sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]); if (w > 0.000001f) { p[0] /= w; p[1] /= w; p[2] /= w; } return w; } }