Package repast.simphony.space.grid
Class WrapAroundBorders
- java.lang.Object
-
- repast.simphony.space.grid.WrapAroundBorders
-
- All Implemented Interfaces:
GridPointTranslator
public class WrapAroundBorders extends Object implements 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 Modifier and Type Field Description protected int[]
origin
protected GridDimensions
spaceDimensions
protected int[]
spaceWidths
-
Constructor Summary
Constructors Constructor Description WrapAroundBorders()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
getNewCoord(int dimension, int location)
void
init(GridDimensions dimensions)
Initializes this with the given dimensions.boolean
isToroidal()
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(GridPoint transformedLocation, int... targetLocation)
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 Detail
-
spaceDimensions
protected transient GridDimensions spaceDimensions
-
spaceWidths
protected transient int[] spaceWidths
-
origin
protected transient int[] origin
-
-
Method Detail
-
init
public void init(GridDimensions dimensions)
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
public void transform(int[] transformedLocation, int... targetLocation) throws SpatialException
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
public void transform(GridPoint transformedLocation, int... targetLocation) throws SpatialException
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.
-
-