edu.columbia.cs.coms4701.geometry
Interface GeometricVector<T extends java.lang.Number>

All Superinterfaces:
java.lang.Iterable<T>
All Known Implementing Classes:
AbstractVector, DiscretePoint2D, DiscreteVector

public interface GeometricVector<T extends java.lang.Number>
extends java.lang.Iterable<T>

Interface for classes that represent n-dimensional vector in a module (i.e. a commutative ring, e.g. reals, integers, complex,...)

Note that a GeometricVector represents an *immutable* data structure. Hence appropriate constructors should be provided to set the dimension and components of a vector.

Version:
0.1

User: aaron Date: Aug 25, 2006 Time: 9:20:48 AM

Author:
aaron@cs

Field Summary
static int X_DIM
           
static int Y_DIM
           
static int Z_DIM
           
 
Method Summary
 GeometricVector<T> add(GeometricVector<T> theVector)
          add returns a *new* vector, equal to the vector sum of this vector and the argument.
 boolean equals(java.lang.Object obj)
          Implementing classes should override equals in suitable fashion, e.g.
 T getComponent(int theDimension)
          Returns the component in the specified dimension.
 T[] getComponents()
          Returns the components as an array
 int getDimension()
          Return the dimension of this vector.
 double getLength()
          Returns the length (norm) of this vector as a double.
 int hashCode()
          Implementing classes should override hashCode() to synchronize with equals()
 java.util.Iterator<T> iterator()
          Returns an iterator over the components of the vector.
 GeometricVector<T> multiply(T theScalar)
          multiply returns a *new* vector, equal to the scalar multiple of this vector and the argument.
 java.lang.String toString()
          Implementing classes should override toString() to produce a simple string representation, e.g.
 

Field Detail

X_DIM

static final int X_DIM
See Also:
Constant Field Values

Y_DIM

static final int Y_DIM
See Also:
Constant Field Values

Z_DIM

static final int Z_DIM
See Also:
Constant Field Values
Method Detail

equals

boolean equals(java.lang.Object obj)
Implementing classes should override equals in suitable fashion, e.g. considering two vectors equal if they have the same dimension and corresponding components are equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj -
Returns:
boolean indicating equality

hashCode

int hashCode()
Implementing classes should override hashCode() to synchronize with equals()

Overrides:
hashCode in class java.lang.Object

toString

java.lang.String toString()
Implementing classes should override toString() to produce a simple string representation, e.g. (0,2,4)

Overrides:
toString in class java.lang.Object

add

GeometricVector<T> add(GeometricVector<T> theVector)
add returns a *new* vector, equal to the vector sum of this vector and the argument.

Performs a component-by-component addition

Parameters:
theVector - the vector to add, which must be of equal or lesser dimension
Returns:

multiply

GeometricVector<T> multiply(T theScalar)
multiply returns a *new* vector, equal to the scalar multiple of this vector and the argument.

Performs a component-by-component scalar multiplication

Parameters:
theScalar - the scalar to multiply by (may be < 1, or indeed < 0)

iterator

java.util.Iterator<T> iterator()
Returns an iterator over the components of the vector. This permits easy use of the for-each loop over vector components.

Specified by:
iterator in interface java.lang.Iterable<T extends java.lang.Number>

getLength

double getLength()
Returns the length (norm) of this vector as a double. Should use ordinary Euclidean distance unless otherwise specified.


getDimension

int getDimension()
Return the dimension of this vector. Note that the dimension cannot be changed (i.e. must be established at construction time).

Returns:
the dimension of the vector

getComponent

T getComponent(int theDimension)
Returns the component in the specified dimension.

Parameters:
theDimension - specifies which component to retrieve

getComponents

T[] getComponents()
Returns the components as an array