edu.unh.sdb.lattice
Class Point

java.lang.Object
  extended by edu.unh.sdb.common.SpaceID
      extended by edu.unh.sdb.lattice.Point
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
GIterator

public class Point
extends SpaceID

Represent a location in the geometry


Field Summary
protected  float[] axes
           
 
Constructor Summary
Point(Datum datum)
          Create point with the axis values given in a Datum
Point(double x)
          Create a one dimensional point with the given axis value.
Point(double x, double y)
          Create a two dimensional point with the given axis values.
Point(double x, double y, double z)
          Create a three dimensional point with the given axis values.
Point(float[] coords)
          Create point with the coord values given in an array of floats.
Point(float[] coords, int startIndex, int numCoords)
          Create a point with the coord values interleaved in an array of floats.
Point(int n)
          Create a point with n dimensions.
Point(Point p)
          Create a copy of the Point parameter.
 
Method Summary
 void add(Point dsd)
          For each axis of this Point, add the value of the corresponding axis of the parameter.
 void assign(float[] coords, int pointIndex, int numCoords)
          Deprecated. Use setCoords( float[], int startIndex, int numCoords ). Note that the semantics of the start position is different in setCoords.
 void assign(Point id)
          Set the axes of this id to the axes of the parameter id.
 java.lang.Object clone()
          Return a copy of this point.
 boolean containedBy(GBounds db)
          Returns true if this Point is contained by the ISBounds parameter, or false otherwise.
 int dim()
          Returns the dimensionality of this Point.
 float distance(Point p)
          Compute the euclidean distance between this point and the argument.
 boolean equal(Point id)
          Return true if parameter is equal to this object, false otherwise.
 float getCoord(int axisNumber)
          Get the value corresponding to the specified axis.
 float[] getCoords(float[] axes)
          Copy the coordinates into the argument array.
 float getFloatAxis(int axisNumber)
          Get the value corresponding to the specified axis.
 int getIntAxis(int axisNumber)
          Get the value corresponding to the specified axis.
 boolean greaterThanOrEqual(Point dsd)
          A helper function that returns true if all the coordinates of this id are greater than or equal to the corresponding coordinates of the parameter id.
 boolean lessThanOrEqual(Point dsd)
          A helper function that returns true if all the coordinates of this id are less than or equal to the corresponding coordinates of the parameter id.
 Datum makeDatum()
          Returns a new datum that contains the point axes as values.
 void negate()
          Arithmetically negate this Point's axis values.
 void print()
          Print the point coordinates
 void setCoord(int axisnumber, float value)
          Set the specified axis to the specified value.
 void setCoord(int axisnumber, int value)
          Set the specified axis to the specified value.
 void setCoords(float[] coords, int startIndex, int numCoords)
          Assign new coordinate values to an existing Point of the same dimensionality.
 void subtract(Point dsd)
          For each axis of this Point, subtract the value of the corresponding axis of the parameter.
 java.lang.String toString()
          Return a String representing the object.
 java.lang.String toString(java.lang.String indent)
          Return a String representing the object indented by the argument string.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

axes

protected float[] axes
Constructor Detail

Point

public Point(int n)
Create a point with n dimensions.


Point

public Point(double x)
Create a one dimensional point with the given axis value.


Point

public Point(double x,
             double y)
Create a two dimensional point with the given axis values.


Point

public Point(double x,
             double y,
             double z)
Create a three dimensional point with the given axis values.


Point

public Point(Datum datum)
Create point with the axis values given in a Datum


Point

public Point(float[] coords)
Create point with the coord values given in an array of floats.


Point

public Point(float[] coords,
             int startIndex,
             int numCoords)
Create a point with the coord values interleaved in an array of floats. The coordinates are taken from the array beginning at the position specified by the 2nd argument. numCoords values will be copied.


Point

public Point(Point p)
Create a copy of the Point parameter.

Method Detail

makeDatum

public Datum makeDatum()
Returns a new datum that contains the point axes as values.


getIntAxis

public final int getIntAxis(int axisNumber)
Get the value corresponding to the specified axis.


getFloatAxis

public final float getFloatAxis(int axisNumber)
Get the value corresponding to the specified axis.


getCoord

public float getCoord(int axisNumber)
Get the value corresponding to the specified axis.


getCoords

public float[] getCoords(float[] axes)
Copy the coordinates into the argument array. A reference to the argument is returned.


setCoord

public void setCoord(int axisnumber,
                     float value)
Set the specified axis to the specified value.

Overrides:
setCoord in class SpaceID

setCoord

public final void setCoord(int axisnumber,
                           int value)
Set the specified axis to the specified value.

Overrides:
setCoord in class SpaceID

clone

public java.lang.Object clone()
Return a copy of this point.

Specified by:
clone in class SpaceID

dim

public final int dim()
Returns the dimensionality of this Point.

Specified by:
dim in class SpaceID

assign

public void assign(Point id)
Set the axes of this id to the axes of the parameter id. The assign method may elect to refer to the data in the parameter id, and not make a copy of this information.


assign

public void assign(float[] coords,
                   int pointIndex,
                   int numCoords)
Deprecated. Use setCoords( float[], int startIndex, int numCoords ). Note that the semantics of the start position is different in setCoords.

Assign new coordinate values to an existing Point of the same dimensionality. The coord values are assumed to be interleaved in an array of floats. The start position is computed by multiplying 2nd arg by the 3rd argument.The 3rd arg specifies how many to copy. If this object is of too small a dimensionality to hold the new coordinates, an error is created.


setCoords

public void setCoords(float[] coords,
                      int startIndex,
                      int numCoords)
Assign new coordinate values to an existing Point of the same dimensionality. The coord values are assumed to be interleaved in an array of floats. The coordinates are taken from the array beginning at the position specified by the 2nd argument; the 3rd arg specifies how many to copy. If this object is of too small a dimensionality to hold the new coordinates, an error is created.


add

public void add(Point dsd)
For each axis of this Point, add the value of the corresponding axis of the parameter. If the dimensionality of the parameter does not match the dimensionality of this object, then a DimensionalityError is created.


negate

public void negate()
Arithmetically negate this Point's axis values.


subtract

public void subtract(Point dsd)
For each axis of this Point, subtract the value of the corresponding axis of the parameter. If the dimensionality of the parameter does not match the dimensionality of this object, then a DimensionalityError is created.


containedBy

public boolean containedBy(GBounds db)
Returns true if this Point is contained by the ISBounds parameter, or false otherwise. If the ISBounds has a different dimensionality than this Point, then a DimensionalityError is created.


equal

public boolean equal(Point id)
Return true if parameter is equal to this object, false otherwise. If the argument has a different dimensionality than this Point, then a DimensionalityError is created.


lessThanOrEqual

public boolean lessThanOrEqual(Point dsd)
A helper function that returns true if all the coordinates of this id are less than or equal to the corresponding coordinates of the parameter id. If any coordinate is greater than the parameter coordinate, then false is returned. If the dimensionality of the parameter does not match the dimensionality of this object, a DimensionalityError is created.


greaterThanOrEqual

public boolean greaterThanOrEqual(Point dsd)
A helper function that returns true if all the coordinates of this id are greater than or equal to the corresponding coordinates of the parameter id. If any coordinate is less than the parameter coordinate, then false is returned. If the dimensionality of the parameter does not match the dimensionality of this object, a DimensionalityError is created.


distance

public float distance(Point p)
Compute the euclidean distance between this point and the argument. The computation is done within the dimensionality of this point.


toString

public java.lang.String toString()
Return a String representing the object.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String indent)
Return a String representing the object indented by the argument string.


print

public void print()
Print the point coordinates