Compute the magnitude (length) of a vector : Vector « Game « Android

Compute the magnitude (length) of a vector


class Main {
   * Compute the magnitude (length) of a vector
   * @param vector
   *            The vector
   * @return The magnitude of the vector
  public static float magnitude(float[] vector) {
    return (float) Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1]
        + vector[2] * vector[2]);


Related examples in the same category

1.Wrapper activity demonstrating the use of the new SensorEvent rotation vector sensor, Sensor#TYPE_ROTATION_VECTOR TYPE_ROTATION_VECTOR}).
2.Vector2d structure
3.Vector2 Structure
4.Convenience library to do vector calculations
6.Bit Vector
7.Compute the dot product of two vectors
8.Compute the cross product of two vectors
9.Vector3 structure