Package repast.simphony.space.continuous
Class BouncyBorders
java.lang.Object
repast.simphony.space.continuous.AbstractPointTranslator
repast.simphony.space.continuous.BouncyBorders
- All Implemented Interfaces:
PointTranslator
Calculates a new location by translating a current one. If the new location is outside some
specified bounds then, the new location will be calculated by "bouncing" off the boundaries. This
assumes that any boundaries are either horizontal or vertical such that the "bounce" only
involves a simple sign change of the direction vector.
- Author:
- Nick Collier
-
Constructor Summary
ConstructorDescriptionConstructs a BouncyBorders translator that must have itsinit(repast.simphony.space.Dimensions)
method called before it is used.BouncyBorders
(double... dimensions) Creates a BounceTranslator whose boundaries are the specified dimensions.BouncyBorders
(double[] dimensions, double[] origin) Creates a BounceTranslator whose boundaries are the specified dimensions. -
Method Summary
Modifier and TypeMethodDescriptionvoid
init
(Dimensions dimensions) Initializes this with the given dimensions.boolean
True if this translator is periodic (in the sense that moving off one border makes you appear on the other one), otherwise false.void
translate
(double[] location, double... displacement) Translate the specified location by the specified displacement.void
Translate the specified location by the specified displacement.For example, if the location is (3, 4) and the displacement is (1, -2), the new location will be (4, 2).Methods inherited from class repast.simphony.space.continuous.AbstractPointTranslator
boundsCheck, minusEpsilon, transform, transform
-
Constructor Details
-
BouncyBorders
public BouncyBorders()Constructs a BouncyBorders translator that must have itsinit(repast.simphony.space.Dimensions)
method called before it is used. This is the standard constructor. -
BouncyBorders
public BouncyBorders(double... dimensions) Creates a BounceTranslator whose boundaries are the specified dimensions. A boundary is created from each dimension having a min of 0 and a max of dimension - 1.- Parameters:
dimensions
-
-
BouncyBorders
public BouncyBorders(double[] dimensions, double[] origin) Creates a BounceTranslator whose boundaries are the specified dimensions. A boundary is created from each dimension having a min of 0 and a max of dimension - 1.- Parameters:
dimensions
-
-
-
Method Details
-
translate
Translate the specified location by the specified displacement.For example, if the location is (3, 4) and the displacement is (1, -2), the new location will be (4, 2). The new location will be copied into the newLocation array.- Parameters:
location
- the current locationnewLocation
- this will hold the newLocation after the method has completeddisplacement
- the amount to translate
-
translate
public void translate(double[] location, double... displacement) Translate the specified location by the specified displacement. The new location will stored in the location array. For example, if the location is (3, 4) and the displacement is (1, -2), the new location will be (4, 2).This will bounce off of any boundaries if necessary.
- Parameters:
location
- the current locationdisplacement
- the amount to translate
-
init
Description copied from class:AbstractPointTranslator
Initializes this with the given dimensions.- Specified by:
init
in interfacePointTranslator
- Overrides:
init
in classAbstractPointTranslator
- Parameters:
dimensions
- the dimensions of the space
-
isPeriodic
public boolean isPeriodic()Description copied from interface:PointTranslator
True if this translator is periodic (in the sense that moving off one border makes you appear on the other one), otherwise false.- Returns:
- true if this translator is periodic, otherwise false.
-