hmi.math
Class Vecf

java.lang.Object
  extended by hmi.math.Vecf

public final class Vecf
extends Object

A collection of methods for vectors of arbitrary length represented by float arrays.

Author:
Herwin van Welbergen, Job Zwiers

Constructor Summary
private Vecf()
           
 
Method Summary
static void add(float[] dst, float[] a)
          Adds vector b to vector a.
static void add(float[] dst, float[] a, float[] b)
          Adds vector a and b, puts result in dest.
static float dot(float[] a, float[] b)
          Calculates the dot product for two vectors of length 3
static boolean epsilonEquals(float[] a, float[] b, float epsilon)
          Tests for equality of vector components within epsilon.
static boolean equals(float[] a, float[] b)
          Tests for equality of two vectors
static float[] getVecf(float[] vecf)
          Rturns a new float[3] array with initialized components
static float[] getVecf(int len)
          Returns a new float[] array with zero components
static void interpolate(float[] dst, float[] a, float[] b, float alpha)
          Linear interpolates between vector a and b, and puts the result in vector dst: dst = (1-alpha)*a + alpha*b
static float length(float[] a)
          returns the vector length
static float lengthSq(float[] a)
          returns the square of the vector length
static void negate(float[] dst)
          Negates a vector
static void negate(float[] dst, float[] src)
          Sets vector dst to the negated version of vector src
static void normalize(float[] a)
          Normalizes a, that is, a = a/|a|
static void normalize(float[] dst, float[] a)
          Normalizes a, that is, dst = a/|a|
static void pmul(float[] dst, float[] a, float[] b)
          Scales a vector
static void scale(float scale, float[] dst)
          Scales a vector
static void scale(float scale, float[] dst, float[] src)
          Scales a vector
static void set(float[] dst, float[] src)
          Copies vector src to vector dst.
static void sub(float[] dst, float[] a)
          Adds vector b to vector a.
static void sub(float[] dst, float[] a, float[] b)
          Adds vector a and b, puts result in dest.
static String toString(float[] config)
          Returns a String of the form (v[0], v[1], ....)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vecf

private Vecf()
Method Detail

getVecf

public static float[] getVecf(int len)
Returns a new float[] array with zero components


getVecf

public static float[] getVecf(float[] vecf)
Rturns a new float[3] array with initialized components


equals

public static boolean equals(float[] a,
                             float[] b)
Tests for equality of two vectors


epsilonEquals

public static boolean epsilonEquals(float[] a,
                                    float[] b,
                                    float epsilon)
Tests for equality of vector components within epsilon.


toString

public static String toString(float[] config)
Returns a String of the form (v[0], v[1], ....)


set

public static void set(float[] dst,
                       float[] src)
Copies vector src to vector dst.


add

public static void add(float[] dst,
                       float[] a,
                       float[] b)
Adds vector a and b, puts result in dest.


add

public static void add(float[] dst,
                       float[] a)
Adds vector b to vector a.


sub

public static void sub(float[] dst,
                       float[] a,
                       float[] b)
Adds vector a and b, puts result in dest.


sub

public static void sub(float[] dst,
                       float[] a)
Adds vector b to vector a.


scale

public static void scale(float scale,
                         float[] dst)
Scales a vector


scale

public static void scale(float scale,
                         float[] dst,
                         float[] src)
Scales a vector


pmul

public static void pmul(float[] dst,
                        float[] a,
                        float[] b)
Scales a vector


negate

public static void negate(float[] dst,
                          float[] src)
Sets vector dst to the negated version of vector src


negate

public static void negate(float[] dst)
Negates a vector


dot

public static float dot(float[] a,
                        float[] b)
Calculates the dot product for two vectors of length 3


lengthSq

public static float lengthSq(float[] a)
returns the square of the vector length


length

public static float length(float[] a)
returns the vector length


interpolate

public static void interpolate(float[] dst,
                               float[] a,
                               float[] b,
                               float alpha)
Linear interpolates between vector a and b, and puts the result in vector dst: dst = (1-alpha)*a + alpha*b


normalize

public static void normalize(float[] dst,
                             float[] a)
Normalizes a, that is, dst = a/|a|

Parameters:
a - vector to be normalized
dst - vector to receive the result

normalize

public static void normalize(float[] a)
Normalizes a, that is, a = a/|a|

Parameters:
a - vector to be normalized