|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Grid3D
Define basic neighborhood functions for 3D Grids. The basic interface defines a width and a height (not all grids require a width and a height unless you're doing toroidal grids), and basic math for toroidal computation.
If you're using the Grid to define a toroidal (wrap-around) world, you can use the tx and ty and tz methods to simplify the math for you. For example, to increment in the x direction, including wrap-around, you can do: x = tx(x+1).
If you're sure that the values you'd pass into the toroidal functions would not wander off more than a grid dimension in either direction (height, width, length), you can use the slightly faster toroidal functions stx and sty and stz instead. For example, to increment in the x direction, including wrap-around, you can do: x = stx(x+1). See the documentation on these functions for when they're appropriate to use. Under most common situations, they're okay.
In HotSpot 1.4.1, stx, sty, and stz are inlined. In Hotspot 1.3.1, they are not (they contain if-statements).
While this interface defines various methods common to many grids, you should endeavor not to call these grids casted into this interface: it's slow. If you call the grids' methods directly by their class, their methods are almost certain to be inlined into your code, which is very fast.
Method Summary | |
---|---|
int |
getHeight()
Get the height |
int |
getLength()
Get the length |
void |
getNeighborsHamiltonianDistance(int x,
int y,
int z,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Gets all neighbors of a location that satisfy abs(x-X) + abs(y-Y) + abs(z-Z) <= dist. |
void |
getNeighborsMaxDistance(int x,
int y,
int z,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Gets all neighbors of a location that satisfy max( abs(x-X) , abs(y-Y), abs(z-Z) ) <= dist. |
int |
getWidth()
Get the width |
int |
stx(int x)
Simple [and fast] toroidal x. |
int |
sty(int y)
Simple [and fast] toroidal y. |
int |
stz(int z)
Simple [and fast] toroidal z. |
int |
tx(int x)
Toroidal x. |
int |
ty(int y)
Toroidal y. |
int |
tz(int z)
Toroidal z. |
Method Detail |
---|
int getWidth()
int getHeight()
int getLength()
int tx(int x)
int ty(int y)
int tz(int z)
int stx(int x)
int sty(int y)
int stz(int z)
void getNeighborsMaxDistance(int x, int y, int z, int dist, boolean toroidal, IntBag xPos, IntBag yPos, IntBag zPos)
void getNeighborsHamiltonianDistance(int x, int y, int z, int dist, boolean toroidal, IntBag xPos, IntBag yPos, IntBag zPos)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |