maze.geometry
Class RectGeometry

java.lang.Object
  extended bymaze.geometry.MazeGeometry
      extended bymaze.geometry.RectGeometry

public class RectGeometry
extends MazeGeometry

Facts about the current maze geometry. In this case it is a bounded rectangular geometry. Methods are available which will transform a coordinate and a direction into a new coordinate. Directions can be absolute directions or a direction and an angle.


Field Summary
protected static int East
          Cardinal direction East for this geometry.
protected static int North
          Cardinal direction North for this geometry.
protected static int South
          Cardinal direction South for this geometry.
protected static int West
          Cardinal direction West for this geometry.
 
Fields inherited from class maze.geometry.MazeGeometry
Debug, hMax, hScale, MAX_DIRECTIONS, origin, P1, P2, vMax, vScale
 
Constructor Summary
RectGeometry(int h, int v)
          Creates a new RectGeometry with the given horizontal and vertical extent.
 
Method Summary
 Coordinate advance(Coordinate c, int d)
          Compute a new coordinate, given a coordinate and an absolute direction
protected  double cellRadius()
          Computes the center-to-vertex distance for a cell with this geometry.
protected  Coordinate east(Coordinate c)
          Computes the coordinates offset to the East.
static java.lang.String label(int d)
          Creates a String label for a given direction
static java.lang.String label(int dir, int angle)
          Creates a String label for a direction offset by an angle.
protected  Coordinate north(Coordinate c)
          Computes the coordinates offset to the North.
protected  Coordinate south(Coordinate c)
          Computes the coordinates offset to the South.
 int startDir()
          Finds a good starting pair of directions, must be distinct
protected  Coordinate west(Coordinate c)
          Computes the coordinates offset to the West.
 
Methods inherited from class maze.geometry.MazeGeometry
advance, cellHoffset, cellPoly, cellVoffset, iterator, left, opp, right, setRect, setTiling, start, turn, wallP1, wallP2, wallPoly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

North

protected static final int North
Cardinal direction North for this geometry. This direction is decreasing vertical coordinates.

See Also:
Constant Field Values

South

protected static final int South
Cardinal direction South for this geometry. This direction is increasing vertical coordinates.

See Also:
Constant Field Values

East

protected static final int East
Cardinal direction East for this geometry. This direction is increasing horizontal coordinates.

See Also:
Constant Field Values

West

protected static final int West
Cardinal direction West for this geometry. This direction is decreasing horizontal coordinates.

See Also:
Constant Field Values
Constructor Detail

RectGeometry

public RectGeometry(int h,
                    int v)
Creates a new RectGeometry with the given horizontal and vertical extent.

Parameters:
h - int horizontal size of the geometry.
v - int vertical size of the geometry.
Method Detail

label

public static java.lang.String label(int d)
Creates a String label for a given direction

Parameters:
d - int direction.
Returns:
String label for a given direction.

label

public static java.lang.String label(int dir,
                                     int angle)
Creates a String label for a direction offset by an angle.

Parameters:
dir - int base direction.
angle - int angle of offset.
Returns:
String label for the given direction and angle.

north

protected Coordinate north(Coordinate c)
Computes the coordinates offset to the North.

Parameters:
c - Coordinates for a cell.
Returns:
Coordinates for a cell offset to the North.

south

protected Coordinate south(Coordinate c)
Computes the coordinates offset to the South.

Parameters:
c - Coordinates for a cell.
Returns:
Coordinates for a cell offset to the South.

west

protected Coordinate west(Coordinate c)
Computes the coordinates offset to the West.

Parameters:
c - Coordinates for a cell.
Returns:
Coordinates for a cell offset to the West.

east

protected Coordinate east(Coordinate c)
Computes the coordinates offset to the East.

Parameters:
c - Coordinates for a cell.
Returns:
Coordinates for a cell offset to the East.

advance

public Coordinate advance(Coordinate c,
                          int d)
Compute a new coordinate, given a coordinate and an absolute direction

Specified by:
advance in class MazeGeometry
Parameters:
c - Coordinate initial location.
d - int direction offset from the initial coordinate.
Returns:
New Coordinate, offset from initial coordinate by a given direction.

startDir

public int startDir()
Finds a good starting pair of directions, must be distinct

Overrides:
startDir in class MazeGeometry
Returns:
int initial direction.

cellRadius

protected double cellRadius()
Computes the center-to-vertex distance for a cell with this geometry. Rectangular tiling goes from edge to edge, r is a function of hScale such that the W edge to E edge distance = hScale

Returns:
double cell radius.