Class BouncyBorders

  • All Implemented Interfaces:
    PointTranslator

    public class BouncyBorders
    extends AbstractPointTranslator
    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 Detail

      • BouncyBorders

        public BouncyBorders()
        Constructs a BouncyBorders translator that must have its init(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 Detail

      • translate

        public void translate​(NdPoint location,
                              double[] newLocation,
                              double... displacement)
        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.

        This will bounce off of any boundaries if necessary.

        Parameters:
        location - the current location
        newLocation - this will hold the newLocation after the method has completed
        displacement - 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 location
        displacement - the amount to translate
      • 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.