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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
getNewCoord
(int dimension, int location) void
init
(GridDimensions dimensions) Initializes this with the given dimensions.boolean
True if this grid is toroidal (in the sense that moving off one border makes you appear on the other one), otherwise false.void
transform
(int[] transformedLocation, int... targetLocation) Transform the given targetLocation according to periodic "wrapped" semantics.void
Transform the given targetLocation according to periodic "wrapped" semantics.void
translate
(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:
init
in 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:
translate
in 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:
transform
in 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:
transform
in 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:GridPointTranslator
True if this grid is toroidal (in the sense that moving off one border makes you appear on the other one), otherwise false.- Specified by:
isToroidal
in interfaceGridPointTranslator
- Returns:
- true if this grid is toroidal, otherwise false.
-