public class SparseGrid3D extends SparseField implements Grid3D, SparseField3D
Generally speaking, if you have a grid of objects, one per location, you should use an ObjectGrid3D. If you have a large grid occupied by a few objects, or those objects can pile up on the same grid location, you should use a SparseGrid3D.
In either case, you might consider storing the location of an object IN THE OBJECT ITSELF if you need to query for the object location often -- it's faster than the hashtable lookup in SparseGrid3D, and certainly faster than searching the entire array of an ObjectGrid3D.
Boundaries. SparseGrid3D has no boundaries at all. width and height and length exist only to allow
you to define pseudo-boundaries for toroidal computation; and to provide typical bounds for visualization. But you can
attach any coordinate as a location for an object with no restrictions.
Setting and getting an object and its Location. The method setObjectLocation(...) methods set the location of the object
(to an Int3D or an Neighborhood Lookups. The method getObjectsAtLocationOfObject returns all Objects at the same location as the provided
object (in a Bag, which must NOT modify). The various getNeighbors...Distance(...) methods return all locations defined by certain
distance bounds, or all the objects stored at those locations. They are expensive to compute and it may be wiser to compute them by hand
if there aren't many.
SparseField.LocationAndIndex
Modifier and Type | Field and Description |
---|---|
protected int |
height |
protected int |
length |
protected int |
width |
allObjects, ANY_SIZE, INITIAL_BAG_SIZE, LARGE_BAG_RATIO, locationAndIndexHash, MIN_BAG_SIZE, objectHash, removeEmptyBags, replaceLargeBags, REPLACEMENT_BAG_RATIO
Constructor and Description |
---|
SparseGrid3D(int width,
int height,
int length) |
SparseGrid3D(SparseGrid3D values) |
Modifier and Type | Method and Description |
---|---|
Double3D |
getDimensions()
Returns the width and height of the sparse field as a Double3D
|
int |
getHeight()
Returns the height of the grid
|
int |
getLength()
Returns the length of the grid
|
void |
getMooreLocations(int x,
int y,
int z,
int dist,
int mode,
boolean includeOrigin,
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.
|
Bag |
getMooreNeighbors(int x,
int y,
int z,
int dist,
int mode,
boolean includeOrigin)
Determines all neighbors of a location that satisfy max( abs(x-X) , abs(y-Y), abs(z-Z) ) <= dist.
|
Bag |
getMooreNeighbors(int x,
int y,
int z,
int dist,
int mode,
boolean includeOrigin,
Bag result,
IntBag xPos,
IntBag yPos,
IntBag zPos) |
Bag |
getMooreNeighborsAndLocations(int x,
int y,
int z,
int dist,
int mode,
boolean includeOrigin,
Bag result,
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.
|
Bag |
getNeighborsHamiltonianDistance(int x,
int y,
int z,
int dist,
boolean toroidal,
Bag result,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Deprecated.
|
void |
getNeighborsHamiltonianDistance(int x,
int y,
int z,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Deprecated.
|
Bag |
getNeighborsMaxDistance(int x,
int y,
int z,
int dist,
boolean toroidal,
Bag result,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Deprecated.
|
void |
getNeighborsMaxDistance(int x,
int y,
int z,
int dist,
boolean toroidal,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Deprecated.
|
Int3D |
getObjectLocation(java.lang.Object obj)
Returns the object location, or null if there is no such object.
|
Double3D |
getObjectLocationAsDouble3D(java.lang.Object obj)
Returns the object location as a Double3D, or as null if there is no such object.
|
Bag |
getObjectsAtLocation(int x,
int y,
int z)
Returns a bag containing all the objects at a given location -- which MIGHT be empty or MIGHT be null
(which should also be interpreted as "empty") when there are no objects at the location.
|
Bag |
getObjectsAtLocations(IntBag xPos,
IntBag yPos,
IntBag zPos,
Bag result)
For each
|
void |
getRadialLocations(int x,
int y,
int z,
double dist,
int mode,
boolean includeOrigin,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Gets all neighbors overlapping with a spherical region centered at (X,Y,Z) and with a radius of dist.
|
void |
getRadialLocations(int x,
int y,
int z,
double dist,
int mode,
boolean includeOrigin,
int measurementRule,
boolean closed,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Gets all neighbors overlapping with a spherical region centered at (X,Y,Z) and with a radius of dist.
|
Bag |
getRadialNeighbors(int x,
int y,
int z,
double dist,
int mode,
boolean includeOrigin) |
Bag |
getRadialNeighbors(int x,
int y,
int z,
double dist,
int mode,
boolean includeOrigin,
Bag result,
IntBag xPos,
IntBag yPos,
IntBag zPos) |
Bag |
getRadialNeighbors(int x,
int y,
int z,
double dist,
int mode,
boolean includeOrigin,
int measurementRule,
boolean closed,
Bag result,
IntBag xPos,
IntBag yPos,
IntBag zPos) |
Bag |
getRadialNeighborsAndLocations(int x,
int y,
int z,
double dist,
int mode,
boolean includeOrigin,
Bag result,
IntBag xPos,
IntBag yPos,
IntBag zPos) |
Bag |
getRadialNeighborsAndLocations(int x,
int y,
int z,
double dist,
int mode,
boolean includeOrigin,
int measurementRule,
boolean closed,
Bag result,
IntBag xPos,
IntBag yPos,
IntBag zPos) |
void |
getVonNeumannLocations(int x,
int y,
int z,
int dist,
int mode,
boolean includeOrigin,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Gets all neighbors of a location that satisfy abs(x-X) + abs(y-Y) + abs(z-Z) <= dist.
|
Bag |
getVonNeumannNeighbors(int x,
int y,
int z,
int dist,
int mode,
boolean includeOrigin)
Determines all neighbors of a location that satisfy abs(x-X) + abs(y-Y) + abs(z-Z) <= dist.
|
Bag |
getVonNeumannNeighbors(int x,
int y,
int z,
int dist,
int mode,
boolean includeOrigin,
Bag result,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Gets all neighbors of a location that satisfy abs(x-X) + abs(y-Y) + abs(z-Z) <= dist.
|
Bag |
getVonNeumannNeighborsAndLocations(int x,
int y,
int z,
int dist,
int mode,
boolean includeOrigin,
Bag result,
IntBag xPos,
IntBag yPos,
IntBag zPos)
Gets all neighbors of a location that satisfy abs(x-X) + abs(y-Y) + abs(z-Z) <= dist.
|
int |
getWidth()
Returns the width of the grid
|
int |
numObjectsAtLocation(int x,
int y,
int z)
Returns the number of objects stored in the grid at the given location.
|
Bag |
removeObjectsAtLocation(int x,
int y,
int z)
Removes all the objects stored at the given location and returns them as a Bag (which you are free to modify).
|
protected void |
removeOrigin(int x,
int y,
int z,
IntBag xPos,
IntBag yPos,
IntBag zPos) |
protected void |
removeOriginToroidal(int x,
int y,
int z,
IntBag xPos,
IntBag yPos,
IntBag zPos) |
boolean |
setObjectLocation(java.lang.Object obj,
Int3D location)
Changes the location of an object, or adds if it doesn't exist yet.
|
boolean |
setObjectLocation(java.lang.Object obj,
int x,
int y,
int z)
Changes the location of an object, or adds if it doesn't exist yet.
|
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 |
stz(int z,
int length) |
int |
tx(int x)
Toroidal x.
|
int |
ty(int y)
Toroidal y.
|
int |
tz(int z)
Toroidal z.
|
buildMap, buildMap, clear, exists, getAllObjects, getObjectIndex, getObjectsAtLocation, getObjectsAtLocationOfObject, getObjectsAtLocations, getRawObjectLocation, getRawObjectsAtLocation, iterator, locationBagIterator, numObjectsAtLocation, numObjectsAtLocationOfObject, remove, removeObjectsAtLocation, setObjectLocation, size
public SparseGrid3D(int width, int height, int length)
public SparseGrid3D(SparseGrid3D values)
public int getWidth()
public int getHeight()
public int getLength()
public final int tx(int x)
Grid3D
public final int ty(int y)
Grid3D
public final int tz(int z)
Grid3D
public int stx(int x)
Grid3D
public int sty(int y)
Grid3D
public int stz(int z)
Grid3D
public final int stz(int z, int length)
public int numObjectsAtLocation(int x, int y, int z)
public Bag getObjectsAtLocation(int x, int y, int z)
public Double3D getObjectLocationAsDouble3D(java.lang.Object obj)
getObjectLocationAsDouble3D
in interface SparseField3D
public Int3D getObjectLocation(java.lang.Object obj)
public Bag removeObjectsAtLocation(int x, int y, int z)
public boolean setObjectLocation(java.lang.Object obj, int x, int y, int z)
public boolean setObjectLocation(java.lang.Object obj, Int3D location)
protected void removeOrigin(int x, int y, int z, IntBag xPos, IntBag yPos, IntBag zPos)
protected void removeOriginToroidal(int x, int y, int z, IntBag xPos, IntBag yPos, IntBag zPos)
public void getNeighborsMaxDistance(int x, int y, int z, int dist, boolean toroidal, IntBag xPos, IntBag yPos, IntBag zPos)
Grid3D
This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so this function is deprecated: instead you should use the other version of this function which has more functionality. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length), that is, the width and height of the grid. if "toroidal", then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
The origin -- that is, the (x,y,z) point at the center of the neighborhood -- is always included in the results.
This function is equivalent to: getNeighborsMaxDistance(x,y,dist,toroidal ? Grid3D.TOROIDAL : Grid3D.BOUNDED, true, xPos, yPos, zPos);
getNeighborsMaxDistance
in interface Grid3D
public void getMooreLocations(int x, int y, int z, int dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos, IntBag zPos)
Grid3D
This function may be run in one of three modes: Grid3D.BOUNDED, Grid3D.UNBOUNDED, and GrideD.TOROIDAL. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length), that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example, SparseGrid3D permits this but ObjectGrid3D and DoubleGrid3D and IntGrid3D and DenseGrid3D do not. Finally if "toroidal", then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin -- that is, the (x,y,z) point at the center of the neighborhood -- in the neighborhood results.
getMooreLocations
in interface Grid3D
public void getNeighborsHamiltonianDistance(int x, int y, int z, int dist, boolean toroidal, IntBag xPos, IntBag yPos, IntBag zPos)
Grid3D
This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so this function is deprecated: instead you should use the other version of this function which has more functionality. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length), that is, the width and height of the grid. if "toroidal", then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
The origin -- that is, the (x,y,z) point at the center of the neighborhood -- is always included in the results.
This function is equivalent to: getNeighborsHamiltonianDistance(x,y,dist,toroidal ? Grid3D.TOROIDAL : Grid3D.BOUNDED, true, xPos, yPos, zPos);
getNeighborsHamiltonianDistance
in interface Grid3D
public void getVonNeumannLocations(int x, int y, int z, int dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos, IntBag zPos)
Grid3D
This function may be run in one of three modes: Grid3D.BOUNDED, Grid3D.UNBOUNDED, and GrideD.TOROIDAL. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length), that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example, SparseGrid3D permits this but ObjectGrid3D and DoubleGrid3D and IntGrid3D and DenseGrid3D do not. Finally if "toroidal", then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin -- that is, the (x,y,z) point at the center of the neighborhood -- in the neighborhood results.
getVonNeumannLocations
in interface Grid3D
public Bag getNeighborsMaxDistance(int x, int y, int z, int dist, boolean toroidal, Bag result, IntBag xPos, IntBag yPos, IntBag zPos)
public Bag getMooreNeighbors(int x, int y, int z, int dist, int mode, boolean includeOrigin, Bag result, IntBag xPos, IntBag yPos, IntBag zPos)
public Bag getMooreNeighborsAndLocations(int x, int y, int z, int dist, int mode, boolean includeOrigin, Bag result, IntBag xPos, IntBag yPos, IntBag zPos)
For each Object which falls within this distance, adds the X position, Y position, Z position, and Object into the
xPos, yPos, zPos, and result Bag, clearing them first.
Some This function may be run in one of three modes: Grid3D.BOUNDED, Grid3D.UNBOUNDED, and Grid3D.TOROIDAL. If "bounded",
then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height, length),
that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example,
SparseGrid3D permits this but ObjectGrid3D and DoubleGrid3D and IntGrid3D and DenseGrid3D do not. Finally if "toroidal",
then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin -- that is, the (x,y) point at the center of the neighborhood -- in the neighborhood results.
public Bag getNeighborsHamiltonianDistance(int x, int y, int z, int dist, boolean toroidal, Bag result, IntBag xPos, IntBag yPos, IntBag zPos)
Then places into the result Bag any Objects which fall on one of these This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so
this function is deprecated: instead you should use the other version of this function which has more functionality.
If "bounded",
then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height, length),
that is, the width and height and length of the grid. if "toroidal",
then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
The origin -- that is, the (x,y,z) point at the center of the neighborhood -- is always included in the results.
This function is equivalent to: getNeighborsHamiltonianDistance(x,y,z,dist,toroidal ? Grid3D.TOROIDAL : Grid3D.BOUNDED, true, result, xPos, yPos,zPos);
public Bag getVonNeumannNeighbors(int x, int y, int z, int dist, int mode, boolean includeOrigin, Bag result, IntBag xPos, IntBag yPos, IntBag zPos)
Then places into the result Bag any Objects which fall on one of these This function may be run in one of three modes: Grid3D.BOUNDED, Grid3D.UNBOUNDED, and Grid3D.TOROIDAL. If "bounded",
then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height),
that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example,
SparseGrid3D permits this but ObjectGrid3D and DoubleGrid3D and IntGrid3D and DenseGrid3D do not. Finally if "toroidal",
then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin -- that is, the (x,y,z) point at the center of the neighborhood -- in the neighborhood results.
public Bag getVonNeumannNeighborsAndLocations(int x, int y, int z, int dist, int mode, boolean includeOrigin, Bag result, IntBag xPos, IntBag yPos, IntBag zPos)
For each Object which falls within this distance, adds the X position, Y position, Z position, and Object into the
xPos, yPos, zPos, and result Bag, clearing them first.
Some This function may be run in one of three modes: Grid3D.BOUNDED, Grid3D.UNBOUNDED, and Grid3D.TOROIDAL. If "bounded",
then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height, length),
that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example,
SparseGrid3D permits this but ObjectGrid3D and DoubleGrid3D and IntGrid3D and DenseGrid3D do not. Finally if "toroidal",
then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin -- that is, the (x,y) point at the center of the neighborhood -- in the neighborhood results.
public Bag getRadialNeighbors(int x, int y, int z, double dist, int mode, boolean includeOrigin, int measurementRule, boolean closed, Bag result, IntBag xPos, IntBag yPos, IntBag zPos)
public Bag getRadialNeighborsAndLocations(int x, int y, int z, double dist, int mode, boolean includeOrigin, int measurementRule, boolean closed, Bag result, IntBag xPos, IntBag yPos, IntBag zPos)
public Bag getObjectsAtLocations(IntBag xPos, IntBag yPos, IntBag zPos, Bag result)
public void getRadialLocations(int x, int y, int z, double dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos, IntBag zPos)
Grid3D
Places each x, y, and z value of these locations in the provided IntBags xPos, yPos, and zPos, clearing the bags first.
This function may be run in one of three modes: Grid3D.BOUNDED, Grid3D.UNBOUNDED, and GrideD.TOROIDAL. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length), that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example, SparseGrid3D permits this but ObjectGrid3D and DoubleGrid3D and IntGrid3D and DenseGrid3D do not. Finally if "toroidal", then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin -- that is, the (x,y,z) point at the center of the neighborhood -- in the neighborhood results.
getRadialLocations
in interface Grid3D
public void getRadialLocations(int x, int y, int z, double dist, int mode, boolean includeOrigin, int measurementRule, boolean closed, IntBag xPos, IntBag yPos, IntBag zPos)
Grid3D
Places each x, y, and z value of these locations in the provided IntBags xPos, yPos, and zPos, clearing the bags first.
This function may be run in one of three modes: Grid3D.BOUNDED, Grid3D.UNBOUNDED, and GrideD.TOROIDAL. If "bounded", then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length), that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example, SparseGrid3D permits this but ObjectGrid3D and DoubleGrid3D and IntGrid3D and DenseGrid3D do not. Finally if "toroidal", then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
You can also opt to include the origin -- that is, the (x,y,z) point at the center of the neighborhood -- in the neighborhood results.
getRadialLocations
in interface Grid3D
public Bag getRadialNeighbors(int x, int y, int z, double dist, int mode, boolean includeOrigin, Bag result, IntBag xPos, IntBag yPos, IntBag zPos)
public Bag getRadialNeighborsAndLocations(int x, int y, int z, double dist, int mode, boolean includeOrigin, Bag result, IntBag xPos, IntBag yPos, IntBag zPos)
public Bag getMooreNeighbors(int x, int y, int z, int dist, int mode, boolean includeOrigin)
Then returns, as a Bag, any Objects which fall on one of these This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded",
then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height),
that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example,
SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal",
then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
public Bag getVonNeumannNeighbors(int x, int y, int z, int dist, int mode, boolean includeOrigin)
Then returns, as a Bag, any Objects which fall on one of these This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded",
then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height),
that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
neighborhood lookup only makes sense if your grid allows locations to actually be outside this box. For example,
SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal",
then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
public Bag getRadialNeighbors(int x, int y, int z, double dist, int mode, boolean includeOrigin)
public final Double3D getDimensions()
SparseField3D
getDimensions
in interface SparseField3D