Here you can find the source of NormalizeVec2D(double[] vec)
public static void NormalizeVec2D(double[] vec)
//package com.java2s; //License from project: Open Source License public class Main { private final static double EPSILON = 0.00000001; public static void NormalizeVec2D(double[] vec) { double one_over_length = 1.0 / Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1] + EPSILON); vec[0] *= one_over_length;/*from w ww . j a v a 2 s .c o m*/ vec[1] *= one_over_length; ; } }