auc.geom
Class Grid2D

java.lang.Object
  |
  +--auc.geom.Grid2D

public class Grid2D
extends java.lang.Object

The grid structure. Use this class to generate the list points in the grid within a field.


Field Summary
protected  Vector2D cellLat
          Latitude size and direction ("horizontal") of the grid cell.
protected  Vector2D cellLong
          Longitude size and direction ("vertical") of the grid cell.
protected  Vector2D gridZero
          The grid zero point is the Descartes coordinates of (0,0) point in the grid.
 
Constructor Summary
Grid2D(Vector2D zero, Vector2D cellLatitude, Vector2D cellLongitude)
          Constructs the initial (complete and infinite) grid.
 
Method Summary
 Vector2D crosses(Segment segment)
          Special method for the evaluator to calculate how many columns and rows of the (crop) grid the route segment crosses.
 Vector2D[][] getArray(Polygon2D poly)
           
 Vector2D getCellLat()
           
 Vector2D getCellLong()
           
 Vector2D getPoint(int latitude, int longitude)
           
 java.util.Vector getPoints(Polygon2D boundary)
          Generates a list of points in the grid of given parameters.
 Vector2D getZeroPoint()
          Gets the grid zero point vector for the grid member [0,0]
 void setCellLat(Vector2D cLat)
          Sets the latitude size and direction ("horizontal") vector for the grid cell
 void setCellLong(Vector2D cLong)
          Sets the longitude size and direction ("vertical") vector for the grid cell
 void setZeroPoint(Vector2D zero)
          Sets the grid zero point vector for the grid member [0,0]
 Vector2D toGridCoord(Vector2D descCoord)
          Method transforms the grid coordinates to the Descartes coordinates.
 Vector2D toRealCoord(Vector2D gridCoord)
          Method transforms the grid coordinates to the Descartes coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gridZero

protected Vector2D gridZero
The grid zero point is the Descartes coordinates of (0,0) point in the grid. This vector is used in transformations between grid and Descartes coordinates.

cellLat

protected Vector2D cellLat
Latitude size and direction ("horizontal") of the grid cell.

cellLong

protected Vector2D cellLong
Longitude size and direction ("vertical") of the grid cell.
Constructor Detail

Grid2D

public Grid2D(Vector2D zero,
              Vector2D cellLatitude,
              Vector2D cellLongitude)
Constructs the initial (complete and infinite) grid. The exclusions and dimensions of the grid are set after generate*() call
Method Detail

setCellLat

public void setCellLat(Vector2D cLat)
Sets the latitude size and direction ("horizontal") vector for the grid cell
Parameters:
cLat - the latitude vector for the grid cell dimention (Descartes coordinates).

getCellLat

public Vector2D getCellLat()

setCellLong

public void setCellLong(Vector2D cLong)
Sets the longitude size and direction ("vertical") vector for the grid cell
Parameters:
cLong - the longitude vector for the grid cell dimention (Descartes coordinates).

getCellLong

public Vector2D getCellLong()

setZeroPoint

public void setZeroPoint(Vector2D zero)
Sets the grid zero point vector for the grid member [0,0]
Parameters:
zero - the vector for the grid starting point (Descartes coordinates).
See Also:
gridZero

getZeroPoint

public Vector2D getZeroPoint()
Gets the grid zero point vector for the grid member [0,0]
Returns:
the vector for the grid starting point (Descartes coordinates).
See Also:
gridZero

toGridCoord

public Vector2D toGridCoord(Vector2D descCoord)
Method transforms the grid coordinates to the Descartes coordinates.
Parameters:
descCoord - the Descartes coordinates (from real world).
Returns:
the point position in grid coordinates.

toRealCoord

public Vector2D toRealCoord(Vector2D gridCoord)
Method transforms the grid coordinates to the Descartes coordinates.
Parameters:
gridCoord - the coordinates which tell the point position in grid.
Returns:
the Descartes coordinates (in real world).

getPoints

public java.util.Vector getPoints(Polygon2D boundary)
Generates a list of points in the grid of given parameters.
Parameters:
start - The starting point of the grid. It always belongs to the grid unless it is outside the field.
horiz - The horizontal (relatively) vector of the grid. The length means the width of grid cell
vert - The vertical (relatively) vector of the grid. The length means height of grid cell.
Returns:
List of points in the grid that belong to field.

getArray

public Vector2D[][] getArray(Polygon2D poly)

getPoint

public Vector2D getPoint(int latitude,
                         int longitude)

crosses

public Vector2D crosses(Segment segment)
Special method for the evaluator to calculate how many columns and rows of the (crop) grid the route segment crosses.
Parameters:
segment - route segment must have at least two points!
Returns:
Vector2D encasulates x - crossed column count and y - crossed row count.