Class BouncyBorders

java.lang.Object
repast.simphony.space.continuous.AbstractPointTranslator
repast.simphony.space.continuous.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 Summary

    Constructors
    Constructor
    Description
    Constructs a BouncyBorders translator that must have its init(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 Type
    Method
    Description
    void
    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(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).

    Methods inherited from class repast.simphony.space.continuous.AbstractPointTranslator

    boundsCheck, minusEpsilon, transform, transform

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • 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 Details

    • 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
    • init

      public void init(Dimensions dimensions)
      Description copied from class: AbstractPointTranslator
      Initializes this with the given dimensions.
      Specified by:
      init in interface PointTranslator
      Overrides:
      init in class AbstractPointTranslator
      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.