|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.geometry.xy.XyGrid
public class XyGrid
A quantization grid or tiling in (x, y) space.
Applying a grid to a geometric space is just like drawing the space on graph paper. The grid is oriented with the cartesian axes such that lines are horizontal and vertical. It may be offset from the (0, 0) origin by its own originX and originY parameters.
A cell width and height is specified; this is the width and height of all cells in the grid. A given cell can be described as a rectangle with minimum and maximum x and y parameters; the cell is understood to contain all values from (minX, minY) inclusive to (maxX, maxY) exclusive. Cells have their own coordinates within the grid, with consists of the number of cells to the left or west and the number of cells beneath or to the south of the cell. This is represented by an XyGridCell object.
As an example, let's present an integer quantization grid with cell width and height of 1.0, and originX and originY of 0.0.
Consider the following four points: (0.5, 0.5), (1.0, 1.0), (3.2, 9.6), and (-8.0, 5.0).
Mathematically, to find the cell for a given coordinate, you subtract the origin, divide by the width or height, and take the integer portion of the result. The offset within the cell is then equal to the remainder times the width or height.
double dividedX = (x - originX) / width; double dividedY = (y - originY) / height; int cellX = (int) Math.floor(dividedX); int cellY = (int) Math.floor(dividedY); double cellOffsetX = (dividedX - cellX) * width; double cellOffsetY = (dividedY - cellY) * height;
Copyright 2007 Partner Software, Inc.
| Constructor Summary | |
|---|---|
XyGrid(double cellSize)
Creates a grid with origin (0, 0) and square cells with the given size. |
|
XyGrid(double cellWidth,
double cellHeight)
Creates a grid with origin (0, 0) and cells with the given width and height. |
|
XyGrid(double originX,
double originY,
double cellSize)
Creates a grid with origin (originX, originY) and square cells with the given size. |
|
XyGrid(double originX,
double originY,
double cellWidth,
double cellHeight)
|
|
XyGrid(XyPoint origin,
XySize cellSize)
|
|
XyGrid(XySize cellSize)
|
|
| Method Summary | |
|---|---|
XyGridCell |
cellContainingPoint(double x,
double y)
|
XyGridCell |
cellContainingPoint(XyPoint point)
|
XySize |
getCellSize()
|
XyPoint |
getOrigin()
|
java.util.List<XyGridCell> |
listCellsIntersecting(XyBounds bounds)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XyGrid(double cellSize)
public XyGrid(double cellWidth,
double cellHeight)
public XyGrid(double originX,
double originY,
double cellSize)
originX - origin of grid (x)originY - origin of grid (y)cellSize - width and height of cells
public XyGrid(double originX,
double originY,
double cellWidth,
double cellHeight)
public XyGrid(XySize cellSize)
public XyGrid(XyPoint origin,
XySize cellSize)
| Method Detail |
|---|
public XyGridCell cellContainingPoint(XyPoint point)
public XyGridCell cellContainingPoint(double x,
double y)
public java.util.List<XyGridCell> listCellsIntersecting(XyBounds bounds)
public XyPoint getOrigin()
public XySize getCellSize()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||