org.ode4j.math
Class DVectorN

java.lang.Object
  extended by org.ode4j.math.DVectorN

public class DVectorN
extends java.lang.Object

An arbitrary length vector.

Author:
Tilmann Zaeschke

Field Summary
static int CURRENT_LENGTH
           
 
Constructor Summary
DVectorN(double[] data)
           
DVectorN(DVectorN v2)
           
DVectorN(int len)
           
 
Method Summary
 DVectorN clone()
           
 double get(int i)
           
 double get0()
           
 double get1()
           
 double get2()
           
 void normalize()
          this may be called for vectors `a' with extremely small magnitude, for example the result of a cross product on two nearly perpendicular vectors.
 boolean safeNormalizeN()
          this may be called for vectors `a' with extremely small magnitude, for example the result of a cross product on two nearly perpendicular vectors.
 void set(double[] a)
           
 void set(int i, double d)
          Set a vector/matrix at position i to a specific value.
 void set0(double d)
           
 void set1(double d)
           
 void set2(double d)
           
 void setIdentity()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CURRENT_LENGTH

public static final int CURRENT_LENGTH
See Also:
Constant Field Values
Constructor Detail

DVectorN

public DVectorN(int len)

DVectorN

public DVectorN(DVectorN v2)

DVectorN

public DVectorN(double[] data)
Method Detail

clone

public DVectorN clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

set0

public void set0(double d)

set1

public void set1(double d)

set2

public void set2(double d)

get0

public double get0()

get1

public double get1()

get2

public double get2()

get

public final double get(int i)

safeNormalizeN

public final boolean safeNormalizeN()
this may be called for vectors `a' with extremely small magnitude, for example the result of a cross product on two nearly perpendicular vectors. we must be robust to these small vectors. to prevent numerical error, first find the component a[i] with the largest magnitude and then scale all the components by 1/a[i]. then we can compute the length of `a' and scale the components by 1/l. this has been verified to work with vectors containing the smallest representable numbers.


normalize

public void normalize()
this may be called for vectors `a' with extremely small magnitude, for example the result of a cross product on two nearly perpendicular vectors. we must be robust to these small vectors. to prevent numerical error, first find the component a[i] with the largest magnitude and then scale all the components by 1/a[i]. then we can compute the length of `a' and scale the components by 1/l. this has been verified to work with vectors containing the smallest representable numbers.


set

public final void set(int i,
                      double d)
Set a vector/matrix at position i to a specific value.


set

public void set(double[] a)

setIdentity

public void setIdentity()