Here you can find the source of normalize(double[] points)
Parameter | Description |
---|---|
points | a parameter |
public static double[] normalize(double[] points)
//package com.java2s; //License from project: Open Source License public class Main { /**//w ww.j a v a2 s . c o m * Normalizes a vector * * @param points * @return points / || points || */ public static double[] normalize(double[] points) { double length = length(points); for (int i = 0; i < points.length; i++) { points[i] = points[i] / length; } return points; } public static double length(double[] point) { return Math.sqrt(stScalarProd(point, point)); } /** * Standard Skalarprodukt to UnitMatrix. * * @param a first vector * @param b second vector * @return <a,b> */ public static double stScalarProd(double[] a, double[] b) { if (a.length != b.length) throw new IllegalArgumentException("Multiplied two Vectors of different length."); double sum = 0; for (int i = 0; i < a.length; i++) { sum += a[i] * b[i]; } return sum; } }