smithers.algorithms
Class Vector

java.lang.Object
  extended by smithers.algorithms.Vector

public class Vector
extends java.lang.Object

Implements a collection of useful vector related algorithms.


Method Summary
static float[] difference(float[] vector1, float[] vector2)
          Computes the difference between two vectors.
static float[] normalise(float[] vector)
          Normalises a vector.
static float scalarProduct(float[] vector1, float[] vector2)
          Computes the scalar product of two vectors.
static float[] sum(float[]... vectors)
          Computes the sum of vectors.
static float tripleProduct(float[] p, float[] q, float[] r)
          Calculates the scalar triple product of 3 vectors.
static float[] vectorProduct(float[] vector1, float[] vector2)
          Computes the vector product of two vectors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sum

public static float[] sum(float[]... vectors)
Computes the sum of vectors.

Parameters:
vectors - some vectors
Returns:
the sum of the vectors

difference

public static float[] difference(float[] vector1,
                                 float[] vector2)
Computes the difference between two vectors.

Parameters:
vector1 - a vector
vector2 - another vector
Returns:
vector1 - vector2

scalarProduct

public static float scalarProduct(float[] vector1,
                                  float[] vector2)
Computes the scalar product of two vectors.

Parameters:
vector1 - a vector
vector2 - another vector
Returns:
vector1vector2

vectorProduct

public static float[] vectorProduct(float[] vector1,
                                    float[] vector2)
Computes the vector product of two vectors. The supplied vectors must both have length 3,

Parameters:
vector1 - a vector
vector2 - another vector
Returns:
vector1×vector2

tripleProduct

public static float tripleProduct(float[] p,
                                  float[] q,
                                  float[] r)
Calculates the scalar triple product of 3 vectors.

Parameters:
p - the first vector
q - the second vector
r - the third vector
Returns:
p(p×q)

normalise

public static float[] normalise(float[] vector)
Normalises a vector.

Parameters:
vector - a vector
Returns:
a unit vector parallel to vector