uchicago.src.sim.space
Class Object2DHexagonalTorus

java.lang.Object
  extended by uchicago.src.sim.space.Object2DGrid
      extended by uchicago.src.sim.space.Object2DHexagonalGrid
          extended by uchicago.src.sim.space.Object2DHexagonalTorus
All Implemented Interfaces:
Discrete2DSpace, Torus

public class Object2DHexagonalTorus
extends Object2DHexagonalGrid
implements Torus

A discrete 2 dimensional hexagonal torus of objects, accessed by x and y coordinates.

The hexagonal cells are referenced by x, y coordinates as follows:

       _
   _ / 1 \ _
 / 0 \ _ / 2 \
 \ _ / 4 \ _ /
 / 3 \ _ / 5 \
 \ _ / 7 \ _ /
 / 6 \ _ / 8 \
 \ _ /   \ _ /

 
Here we have a 3 x 3 hexagonal grid. The first row of cells is 0, 1, 2 such that 0,0 refers to cell 0, and 0,2 refers to cell 2. The next row of cells is 3, 4, 5, so 1,0 refers to cell 3 and so on. The last row of cells is 6, 7, and 8, so 2, 0 refers to cell 6. The ring of neighbors with radius one that surrounds cell 4 is composed of 1, 2, 5, 7, 3, and 0. The grid wraps as a toriod such that cell -1, 0 refers to cell 2 and cell 0, -1 is cell 6.

Version:
$Revision: 1.5 $ $Date: 2004/11/03 19:50:58 $
Author:
Tom Howe

Field Summary
 
Fields inherited from class uchicago.src.sim.space.Object2DGrid
matrix, Mneigh, PGM_ASCII, RASTER_ASCII, VNneigh, xSize, ySize
 
Fields inherited from interface uchicago.src.sim.space.Discrete2DSpace
MOORE, VON_NEUMANN
 
Constructor Summary
Object2DHexagonalTorus(int xSize, int ySize)
          Creates a new torus of the specified size.
 
Method Summary
 java.lang.Object getObjectAt(int x, int y)
          Gets the object at the specified coordinate
 double getValueAt(int x, int y)
          Gets the value at (x,y)
 void putObjectAt(int x, int y, java.lang.Object object)
          Puts the specified object at (x,y), wrapping the coordinates around the torus if necessary.
 void putValueAt(int x, int y, double value)
          Puts the specified double at (x,y), wrapping the coordinates around the torus if necessary.
 int xnorm(int x)
           
 int ynorm(int y)
          Normalize the y value to the toroidal coordinates
 
Methods inherited from class uchicago.src.sim.space.Object2DHexagonalGrid
findMaximum, findMinimum, getMooreNeighbors, getMooreNeighbors, getNeighbors, getNeighbors, getVonNeumannNeighbors, getVonNeumannNeighbors
 
Methods inherited from class uchicago.src.sim.space.Object2DGrid
findMaximum, findMinimum, getMatrix, getSize, getSizeX, getSizeY, rangeCheck, setComparator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Object2DHexagonalTorus

public Object2DHexagonalTorus(int xSize,
                              int ySize)
Creates a new torus of the specified size.

Parameters:
xSize - the size of the x dimension
ySize - the size of the y dimension
Method Detail

putObjectAt

public void putObjectAt(int x,
                        int y,
                        java.lang.Object object)
Puts the specified object at (x,y), wrapping the coordinates around the torus if necessary.

Specified by:
putObjectAt in interface Discrete2DSpace
Overrides:
putObjectAt in class Object2DGrid
Parameters:
x - the x coordinate
y - the y coordinate
object - the object to put at (x,y)

putValueAt

public void putValueAt(int x,
                       int y,
                       double value)
Puts the specified double at (x,y), wrapping the coordinates around the torus if necessary.

Specified by:
putValueAt in interface Discrete2DSpace
Overrides:
putValueAt in class Object2DGrid
Parameters:
x - the x coordinate
y - the y coordinate
value - the value to put at (x,y)

getObjectAt

public java.lang.Object getObjectAt(int x,
                                    int y)
Gets the object at the specified coordinate

Specified by:
getObjectAt in interface Discrete2DSpace
Overrides:
getObjectAt in class Object2DGrid
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
the object at x, y

getValueAt

public double getValueAt(int x,
                         int y)
Gets the value at (x,y)

Specified by:
getValueAt in interface Discrete2DSpace
Overrides:
getValueAt in class Object2DGrid
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
the value at x, y

xnorm

public int xnorm(int x)

ynorm

public int ynorm(int y)
Normalize the y value to the toroidal coordinates

Parameters:
y - the value to normalize
Returns:
the normalized value