edu.columbia.cs.coms4701.geometry
Class DiscreteVector

java.lang.Object
  extended by edu.columbia.cs.coms4701.geometry.AbstractVector<java.lang.Integer>
      extended by edu.columbia.cs.coms4701.geometry.DiscreteVector
All Implemented Interfaces:
GeometricVector<java.lang.Integer>, java.lang.Iterable<java.lang.Integer>
Direct Known Subclasses:
DiscretePoint2D

public class DiscreteVector
extends AbstractVector<java.lang.Integer>

An n-dimensional vector of integers.

Version:
0.1

User: aaron Date: Aug 25, 2006 Time: 11:34:41 AM

Author:
aaron@cs

Field Summary
static DiscreteVector[] DIRECTIONS
          Array of the eight compass directions (the single-step vector in each direction), in clockwise order (North, Northeast, East, Southwest, South, Southwest, West, Northwest).
static DiscreteVector EAST
          East, i.e.
static DiscreteVector NORTH
          North, i.e.
static DiscreteVector NORTHEAST
          Northeast, i.e.
static DiscreteVector NORTHWEST
          Northwest, i.e.
static DiscreteVector SOUTH
          South, i.e.
static DiscreteVector SOUTHEAST
          Southweast, i.e.
static DiscreteVector SOUTHWEST
          Southwest, i.e.
static DiscreteVector WEST
          West, i.e.
 
Fields inherited from class edu.columbia.cs.coms4701.geometry.AbstractVector
components, PRIME
 
Fields inherited from interface edu.columbia.cs.coms4701.geometry.GeometricVector
X_DIM, Y_DIM, Z_DIM
 
Constructor Summary
DiscreteVector(int theDimension)
          Constructs a new vector of the specified dimension.
DiscreteVector(int theDimension, java.lang.Integer... theComponents)
          Constructs a new vector of the specified dimension, with the specified components.
 
Method Summary
 DiscreteVector add(GeometricVector<java.lang.Integer> theVector)
          add returns a *new* vector, equal to the vector sum of this vector and the argument.
 java.lang.Integer[] getComponents()
          Returns the components as an array
 DiscreteVector multiply(java.lang.Integer theScalar)
          multiply returns a *new* vector, equal to the scalar multiple of this vector and the argument.
 
Methods inherited from class edu.columbia.cs.coms4701.geometry.AbstractVector
checkDimension, checkEqualOrSmallerDimensionVector, equals, getComponent, getDimension, getLength, hashCode, iterator, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NORTH

public static final DiscreteVector NORTH
North, i.e. vector (0,1)


NORTHEAST

public static final DiscreteVector NORTHEAST
Northeast, i.e. vector (1,1)


EAST

public static final DiscreteVector EAST
East, i.e. vector (1)


SOUTHEAST

public static final DiscreteVector SOUTHEAST
Southweast, i.e. vector (1,-1)


SOUTH

public static final DiscreteVector SOUTH
South, i.e. vector (0,-1)


SOUTHWEST

public static final DiscreteVector SOUTHWEST
Southwest, i.e. vector (-1,-1)


WEST

public static final DiscreteVector WEST
West, i.e. vector (-1)


NORTHWEST

public static final DiscreteVector NORTHWEST
Northwest, i.e. vector (-1,1)


DIRECTIONS

public static final DiscreteVector[] DIRECTIONS
Array of the eight compass directions (the single-step vector in each direction), in clockwise order (North, Northeast, East, Southwest, South, Southwest, West, Northwest).

Constructor Detail

DiscreteVector

public DiscreteVector(int theDimension)
Constructs a new vector of the specified dimension.

If no components are specified, the vector will be a zero-vector.

Parameters:
theDimension -

DiscreteVector

public DiscreteVector(int theDimension,
                      java.lang.Integer... theComponents)
Constructs a new vector of the specified dimension, with the specified components.

The number of components specified must not exceed the specified dimension (duh). If fewer components are specified than there are dimensions, the remaining components are set to zero.

Parameters:
theDimension -
theComponents -
Throws:
java.lang.IllegalArgumentException - if too many
Method Detail

add

public DiscreteVector add(GeometricVector<java.lang.Integer> theVector)
add returns a *new* vector, equal to the vector sum of this vector and the argument.

Performs a component-by-component addition

Specified by:
add in interface GeometricVector<java.lang.Integer>
Specified by:
add in class AbstractVector<java.lang.Integer>
Parameters:
theVector - the vector to add, which must be of equal or lesser dimension
Returns:
a new vector

multiply

public DiscreteVector multiply(java.lang.Integer theScalar)
multiply returns a *new* vector, equal to the scalar multiple of this vector and the argument.

Performs a component-by-component scalar multiplication

Specified by:
multiply in interface GeometricVector<java.lang.Integer>
Specified by:
multiply in class AbstractVector<java.lang.Integer>
Parameters:
theScalar - the scalar to multiply by (may be < 1, or indeed < 0)

getComponents

public java.lang.Integer[] getComponents()
Description copied from class: AbstractVector
Returns the components as an array

Specified by:
getComponents in interface GeometricVector<java.lang.Integer>
Specified by:
getComponents in class AbstractVector<java.lang.Integer>