Here you can find the source of norm_vec(double[] vec)
public static double[] norm_vec(double[] vec)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 Jay Unruh, Stowers Institute for Medical Research. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v2.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html ******************************************************************************/ public class Main { public static double[] norm_vec(double[] vec) { double norm = Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);/*from ww w . j a v a 2 s .co m*/ double[] temp = { vec[0] / norm, vec[1] / norm, vec[2] / norm }; return temp; } }