Package repast.simphony.space.grid
Class GridPoint
java.lang.Object
repast.simphony.space.grid.GridPoint
Represents an n-dimensional discrete point in a grid.
- Author:
- Nick Collier
-
Field Summary
-
Constructor Summary
ConstructorDescriptionGridPoint
(int... point) Creates a GridPoint from the passed in array of points. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the number of dimensions of this point.boolean
int
getCoord
(int index) Gets the coordinate at the specified index.int
getX()
Gets the x coordinate.int
getY()
Gets the y coordinate.int
getZ()
Gets the z coordinate.int
hashCode()
int[]
toIntArray
(int[] array) Copies the point coordinates into the specified int array.toString()
-
Field Details
-
point
protected int[] point
-
-
Constructor Details
-
GridPoint
public GridPoint(int... point) Creates a GridPoint from the passed in array of points.- Parameters:
point
-
-
-
Method Details
-
getX
public int getX()Gets the x coordinate.- Returns:
- the x coordinate.
-
getY
public int getY()Gets the y coordinate.- Returns:
- the y coordinate.
- Throws:
ArrayIndexOutOfBoundsException
- if this points number of dimensions < 2
-
getZ
public int getZ()Gets the z coordinate.- Returns:
- the z coordinate.
- Throws:
ArrayIndexOutOfBoundsException
- if this points number of dimensions < 3
-
getCoord
public int 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.
-
toIntArray
public int[] toIntArray(int[] array) Copies the point coordinates into the specified int array. If the array is null, a new one is created and returned.- Parameters:
array
- the array to put the point coorindates 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.
-
toString
-
hashCode
public int hashCode() -
equals
-