Android examples for java.lang:Math Vector
Calculates the magnitude of any vector by using Pythagorean principle.
//package com.java2s; public class Main { /**//from www .j ava2 s . c o m * Calculates the magnitude of any vector by using Pythagorean principle. * * @param vectorComponents * @return The vector magnitude. */ public static double getVectorMagnitude(float[] vectorComponents) { double result = 0; for (double d : vectorComponents) { result += Math.pow(d, 2); } return Math.sqrt(result); } }