org.crwth.systems
Class Vector

java.lang.Object
  |
  +--org.crwth.systems.Vector
Direct Known Subclasses:
Vector1d

public abstract class Vector
extends Object

A generic Vector class. A Vector is a vector with support for inversion and magnitude.


Constructor Summary
Vector()
           
 
Method Summary
abstract  void add(Vector vector)
          Adds one vector to another.
abstract  boolean equals(Vector vector)
          Returns true if the coordinates of the object and vector differ by less than a defined epsilon value.
abstract  int getDimension()
          Returns the dimension of the Vector.
abstract  double getDistance(Vector vector)
          Returns the distance to another Vector.
abstract  Vector getInverse()
          Returns a Vector that is inverted along all axes to this object, maintaining the same magnitude.
abstract  double getMagnitude()
          Returns the magnitude of the object.
abstract  Vector getNormal()
          Returns a normal Vector to this Vector; that is, a Vector of magnitude 1 in the same direction as the object.
abstract  Vector getVector(Vector vector)
          Returns a Vector from the object to the endpoint of vector.
abstract  void invert()
          Inverts the object along all axes.
abstract  void normalize()
          Sets the object's magnitude to 1.
abstract  void setMagnitude(double magnitude)
          Sets the magnitude of the object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vector

public Vector()
Method Detail

getDistance

public abstract double getDistance(Vector vector)
                            throws WrongDimensionException
Returns the distance to another Vector.

Parameters:
vector - the other vector.
Returns:
the distance to the object vector
Throws:
WrongDimensionException - if vector has a mismatched dimension.

add

public abstract void add(Vector vector)
                  throws WrongDimensionException
Adds one vector to another.

Parameters:
vector - the Vector to add to the object.
Throws:
WrongDimensionException - if vector has a mismatched dimension.

getVector

public abstract Vector getVector(Vector vector)
                          throws WrongDimensionException
Returns a Vector from the object to the endpoint of vector.

Parameters:
vector - the Vector to calculate to.
Returns:
the Vector from the object to vector.
Throws:
WrongDimensionException - if vector has a mismatched dimension.

getDimension

public abstract int getDimension()
Returns the dimension of the Vector.

Returns:
the dimension of this object.

equals

public abstract boolean equals(Vector vector)
                        throws WrongDimensionException
Returns true if the coordinates of the object and vector differ by less than a defined epsilon value.

Parameters:
vector - the Vector to compare.
Throws:
WrongDimensionException - if vector has a mismatched dimension.

invert

public abstract void invert()
Inverts the object along all axes. Maintains magnitude.


getInverse

public abstract Vector getInverse()
Returns a Vector that is inverted along all axes to this object, maintaining the same magnitude.

Returns:
an inverted Vector.

setMagnitude

public abstract void setMagnitude(double magnitude)
Sets the magnitude of the object.

Parameters:
magnitude - the new magnitude.

getMagnitude

public abstract double getMagnitude()
Returns the magnitude of the object.

Returns:
the object's magnitude.

normalize

public abstract void normalize()
Sets the object's magnitude to 1. Equivalent to setMagnitude(1.0).


getNormal

public abstract Vector getNormal()
Returns a normal Vector to this Vector; that is, a Vector of magnitude 1 in the same direction as the object.

Returns:
a Vector of magnitude 1.

toString

public String toString()
Overrides:
toString in class Object