Package repast.simphony.space.grid
Class WrapAroundBorders
java.lang.Object
repast.simphony.space.grid.WrapAroundBorders
- All Implemented Interfaces:
GridPointTranslator
Periodic type border implementation. Translates and transforms beyond the grid's dimensions
are wrapped around the borders. Creating a 2D grid with these types of border results in a torus.
- Author:
- Jerry Vos
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intgetNewCoord(int dimension, int location) voidinit(GridDimensions dimensions) Initializes this with the given dimensions.booleanTrue if this grid is toroidal (in the sense that moving off one border makes you appear on the other one), otherwise false.voidtransform(int[] transformedLocation, int... targetLocation) Transform the given targetLocation according to periodic "wrapped" semantics.voidTransform the given targetLocation according to periodic "wrapped" semantics.voidtranslate(int[] location, int... displacement) Translates the specified location by the specified displacement according to periodic "wrapped" semantics.
-
Field Details
-
spaceDimensions
-
spaceWidths
protected transient int[] spaceWidths -
origin
protected transient int[] origin
-
-
Constructor Details
-
WrapAroundBorders
public WrapAroundBorders()
-
-
Method Details
-
init
Initializes this with the given dimensions.- Specified by:
initin interfaceGridPointTranslator- Parameters:
dimensions- the dimensions of the space
-
translate
public void translate(int[] location, int... displacement) Translates the specified location by the specified displacement according to periodic "wrapped" semantics. Locations outside the grid will be wrapped into the grid's dimensions. The results will be placed into the location array.- Specified by:
translatein interfaceGridPointTranslator- Parameters:
location- the current locationdisplacement- the amount of displacement
-
transform
Transform the given targetLocation according to periodic "wrapped" semantics. The new transformed coordinates will be placed in the transformedLocation.- Specified by:
transformin interfaceGridPointTranslator- Parameters:
transformedLocation- the coordinates once they have been transformed by this GridPointTranslatortargetLocation- the new target location whose coordinates will be transformed- Throws:
SpatialException- if the transform is invalid.
-
transform
Transform the given targetLocation according to periodic "wrapped" semantics. The new transformed coordinates will be placed in the transformedLocation.- Specified by:
transformin interfaceGridPointTranslator- Parameters:
transformedLocation- the coordinates once they have been transformed by this GridPointTranslatortargetLocation- the new target location whose coordinates will be transformed- Throws:
SpatialException- if the transform is invalid.
-
getNewCoord
protected int getNewCoord(int dimension, int location) -
isToroidal
public boolean isToroidal()Description copied from interface:GridPointTranslatorTrue if this grid is toroidal (in the sense that moving off one border makes you appear on the other one), otherwise false.- Specified by:
isToroidalin interfaceGridPointTranslator- Returns:
- true if this grid is toroidal, otherwise false.
-