Package repast.simphony.space.continuous
Class NdPoint
java.lang.Object
repast.simphony.space.continuous.NdPoint
Represents an n-dimensional point in a space.
- Author:
- Nick Collier
-
Constructor Summary
ConstructorsConstructorDescriptionNdPoint(double... point) Creates a NdPoint from the passed in array of points. -
Method Summary
Modifier and TypeMethodDescriptionintGets the number of dimensions of this point.booleandoublegetCoord(int index) Gets the coordinate at the specified index.intgetCoordInt(int index) doublegetX()Gets the x coordinate.doublegetY()Gets the y coordinate.doublegetZ()Gets the z coordinate.inthashCode()double[]toDoubleArray(double[] array) Copies the point coordinates into the specified double array.toString()
-
Constructor Details
-
NdPoint
public NdPoint(double... point) Creates a NdPoint from the passed in array of points.- Parameters:
point-
-
-
Method Details
-
getX
public double getX()Gets the x coordinate.- Returns:
- the x coordinate.
-
getY
public double getY()Gets the y coordinate.- Returns:
- the y coordinate.
- Throws:
ArrayIndexOutOfBoundsException- if this points number of dimensions < 2
-
getZ
public double getZ()Gets the z coordinate.- Returns:
- the z coordinate.
- Throws:
ArrayIndexOutOfBoundsException- if this points number of dimensions < 3
-
getCoord
public double getCoord(int index) Gets the coordinate at the specified index. The x coordinate is at index 0, y at 1, z at 2 and so on.- Parameters:
index- the index of the coordinate- Returns:
- the coordinate at the specified index.
- Throws:
ArrayIndexOutOfBoundsException- if this points number of dimensions is less than the specified index.
-
dimensionCount
public int dimensionCount()Gets the number of dimensions of this point.- Returns:
- the number of dimensions of this point.
-
toDoubleArray
public double[] toDoubleArray(double[] array) Copies the point coordinates into the specified double array. If the array is null, a new one is created and returned.- Parameters:
array- the array to put the point coordinates in. If the array is null, a new one is created and returned.- Returns:
- an array containing point coordinates sizes.
- Throws:
ArrayIndexOutOfBoundsException- if the passed in array is not the correct length.
-
getCoordInt
public int getCoordInt(int index) -
toString
-
hashCode
public int hashCode() -
equals
-