edu.harvard.syrah.pyxida.nc.lib
Class Coordinate

java.lang.Object
  extended by edu.harvard.syrah.pyxida.nc.lib.Coordinate
All Implemented Interfaces:
java.io.Serializable

public class Coordinate
extends java.lang.Object
implements java.io.Serializable

A coordinate in the Euclidian space.

See Also:
Serialized Form

Field Summary
protected static int CLASS_HASH
           
protected  double[] coords
           
static double MIN_COORD
           
protected  int num_dims
           
protected  byte version
           
 
Constructor Summary
protected Coordinate(Coordinate c)
           
protected Coordinate(double[] init_pos, boolean make_copy)
          Creates a new coordinate having a position specified by the array init_coords.
  Coordinate(float[] init_pos)
          Creates a new coordinate having a position specified by the array init_coords.
  Coordinate(int num_dimensions)
          Creates a new coordinate having a position at the origin.
  Coordinate(int num_dimensions, java.io.DataInputStream dis)
           
 
Method Summary
 void add(Vec v)
           
protected  boolean assign(Coordinate c)
           
 Vec asVectorFromZero(boolean make_copy)
           
 boolean atOrigin()
           
 void bump()
          Move a small distance along each dimension from where we are currently.
 void checkHeight()
           
 double distanceTo(Coordinate c)
           
 double distanceToNonOriginCoord(Coordinate c)
          Returns the Euclidian distance to the given coordinate parameter.
 boolean equals(java.lang.Object obj)
           
protected  Vec getDirection(Coordinate c)
           
 int getNumDimensions()
          Returns the number of dimensions this coordinate has.
 byte getVersion()
           
 int hashCode()
           
 boolean isCompatible(Coordinate _other)
           
 boolean isValid()
           
 Coordinate makeCopy()
          Creates a copy of this Coordinate object, such that updates in this coordinate are not reflected in the returned object.
protected  void reset()
           
 void toSerialized(java.io.DataOutputStream dos)
           
 java.lang.String toString()
           
 java.lang.String toStringAsVector()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_HASH

protected static final int CLASS_HASH

coords

protected final double[] coords

version

protected final byte version

num_dims

protected final int num_dims

MIN_COORD

public static double MIN_COORD
Constructor Detail

Coordinate

public Coordinate(int num_dimensions)
Creates a new coordinate having a position at the origin.

Parameters:
num_dimensions - the number of coordinate dimensions

Coordinate

public Coordinate(int num_dimensions,
                  java.io.DataInputStream dis)
           throws java.io.IOException
Parameters:
num_dimensions -
dis -
Throws:
java.io.IOException

Coordinate

protected Coordinate(Coordinate c)

Coordinate

protected Coordinate(double[] init_pos,
                     boolean make_copy)
Creates a new coordinate having a position specified by the array init_coords. The number of dimensions is this equal to the array length.

Parameters:
init_pos - the position for this coordinate
make_copy - whether a copy of the array should be made

Coordinate

public Coordinate(float[] init_pos)
Creates a new coordinate having a position specified by the array init_coords. The number of dimensions is this equal to the array length.

Parameters:
init_pos - the position for this coordinate
Method Detail

getVersion

public byte getVersion()

makeCopy

public Coordinate makeCopy()
Creates a copy of this Coordinate object, such that updates in this coordinate are not reflected in the returned object.

Returns:
a copy of these coordinates

toSerialized

public void toSerialized(java.io.DataOutputStream dos)
                  throws java.io.IOException
Throws:
java.io.IOException

isCompatible

public boolean isCompatible(Coordinate _other)

bump

public void bump()
Move a small distance along each dimension from where we are currently.


getNumDimensions

public int getNumDimensions()
Returns the number of dimensions this coordinate has.

Returns:
the number of coordinate dimensions.

distanceToNonOriginCoord

public double distanceToNonOriginCoord(Coordinate c)
Returns the Euclidian distance to the given coordinate parameter.

Parameters:
c - the coordinate to find the Euclidian distance to
Returns:
the distance to parameter c

distanceTo

public double distanceTo(Coordinate c)

add

public void add(Vec v)

getDirection

protected Vec getDirection(Coordinate c)

assign

protected boolean assign(Coordinate c)

checkHeight

public void checkHeight()

atOrigin

public boolean atOrigin()

asVectorFromZero

public Vec asVectorFromZero(boolean make_copy)

isValid

public boolean isValid()

reset

protected void reset()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

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

toStringAsVector

public java.lang.String toStringAsVector()