Class WrapAroundBorders

  • All Implemented Interfaces:
    PointTranslator

    public class WrapAroundBorders
    extends AbstractPointTranslator
    Periodic type border implementation. Translates and transforms beyond the space's dimensions are wrapped around the borders. Creating a 2D space with these types of border results in a torus.
    Author:
    Jerry Vos
    • Field Detail

      • spaceWidths

        protected transient double[] spaceWidths
      • origin

        protected transient double[] origin
      • newLocationWrapped

        protected transient boolean newLocationWrapped
    • Constructor Detail

      • WrapAroundBorders

        public WrapAroundBorders()
    • Method Detail

      • isNewLocationWrapped

        public boolean isNewLocationWrapped()
      • setNewLocationWrapped

        public void setNewLocationWrapped​(boolean newCoordinateWrapped)
      • translate

        public void translate​(double[] location,
                              double... displacement)
        Translates the specified location by the specified displacement according to periodic "wrapped" semantics. Locations outside the grid will be wrapped into the spaces's dimensions. The results will be placed into the location array.
        Parameters:
        location - the current location
        displacement - the amount of displacement
      • translate

        public void translate​(NdPoint location,
                              double[] newLocation,
                              double... displacement)
        Translates the specified location by the specified displacement according to periodic "wrapped" semantics. Locations outside the grid will be wrapped into the spaces's dimensions. The results will be placed into the newLocation array.
        Parameters:
        location - the current location
        newLocation - holds the newLocation after the method has completed
        displacement - the amount of displacement
      • transform

        public void transform​(double[] transformedLocation,
                              double... targetLocation)
        Transform the given targetLocation according to periodic "wrapped" semantics. The new transformed coordinates will be placed in the transformedLocation.
        Specified by:
        transform in interface PointTranslator
        Overrides:
        transform in class AbstractPointTranslator
        Parameters:
        transformedLocation - coordinates holds the current location and the new coordinates once they have been transformed by this PointTranslator
        targetLocation - the new target location whose coordinates will be transformed
        Throws:
        SpatialException - if the transform is invalid.
      • transform

        public void transform​(NdPoint transformedLocation,
                              double... targetLocation)
        Transform the given targetLocation according to periodic "wrapped" semantics. The new transformed coordinates will be placed in the transformedLocation.
        Specified by:
        transform in interface PointTranslator
        Overrides:
        transform in class AbstractPointTranslator
        Parameters:
        transformedLocation - holds the original coordinates and the new coordinates once they have been transformed by this PointTranslator
        targetLocation - the new target location whose coordinates will be transformed
        Throws:
        SpatialException - if the transform is invalid.
      • getNewCoord

        protected double getNewCoord​(int dimension,
                                     double location)
      • 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.