These pages are auto-generated from self-documenting comments embedded in class files.
For more information on breve and steve, refer to the breve homepage.

## Abstract : Patch

This class is included as part of the file Patch.tz.
To use this class in a simulation, include the line "@use Patch."

### Class description:

> A patch is a non-physical object which is associated with a specific location in space. A patch can hold information about the state of the world in that location, such as the presence of a nutrient, for example. See the object PatchGrid for more information on setting up patches. Patches must be set up as part of a PatchGrid.

> Because patches are not physical, they cannot move and they cannot collide with other objects. Though you can find the patch that an object is in, there is no collision callback when an object enters the patch. Patches can track the concentration of objects in their space. Currently this is limited to PatchChemical objects which are used to track information about abstract diffusable elements in the world. You can get the concentration, set the concentration, add and remove PatchChemcicals through the patch. See PatchGrid for adding PatchChemcials to the simulation and to iterate the diffusion. It is important to note that concentrations are stored in single precision floats currently to improve performance on hardware that supports SIMD processing.

> The methods used to find neighboring patches depends on the type of simulation you're running. Though many of the "get-patch" methods described below behave the same as one another, they are named differently to be consistent with different types of simulations.

> The neighbors are not fully initialized at the time that the init method is called. This is because the CLASS(PatchGrid) must create all of the patches before it can initialize the neighbors. Instead of accessing the neighbors in the init method, you should implement your own init-patch and place all initialization inside this method. The neighbors for the patch will be fully initialized by the time the init-patch method is called.

> When using a 2D XY style simulation, use the following methods to get the four cardinal directions: get-patch-to-left, get-patch-to-right, get-patch-above and get-patch-below.

> When using a 3D style simulation with and XZ ground plane (such that the vector (0, 1, 0) is pointing up, use the following methods to get the six cardinal directions: get-patch-to-north, get-patch-to-east, get-patch-to-south, get-patch-to-west, get-patch-above and get-patch-below.

> These two groups of methods should suffice for most simulations, but if for some reason you use another orientation for your simulation which doesn't fit well with the vocabulary of these methods, you can use the following methods: get-patch-towards-plus-x, get-patch-towards-minus-x, get-patch-towards-plus-y, get-patch-towards-minus-y, get-patch-towards-plus-z and get-patch-towards-minus-z.

### Class methods:

> Getting Information About a Patch

> - get-index-vector
> - get-location
> - get-x-index
> - get-y-index
> - get-z-index

> Methods to Initialize Patches

> - init-patch

> Changing the Appearence of Patches

> - get-color
> - get-transparency
> - set-color
> - set-transparency

> Getting Groups of Neighbor Patches

> - get-3d-moore-neighborhood
> - get-3d-von-neumann-neighborhood
> - get-moore-neighborhood
> - get-patch
> - get-von-neumann-neighborhood

> Getting Specific Patch Neighbors

> - get-patch-to-left

> Getting Information About a PatchChemicals in the Patch

`get-3d-moore-neighborhood with-size neighborhoodSize = 1 (int)`

> Returns a list of the 3D Moore neighbors of this patch. The 3D Moore neighborhood consists of all patches adjacent to this patch, including diagonally, in three dimensions.

> Due to performance concerns, if you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.

`get-3d-von-neumann-neighborhood with-size neighborhoodSize = 1 (int)`

> Returns a list of the 3D Von Neumann neighbors of this patch. The 3D Von Neumann neighborhood consists of the patches left, right, above, below, in front of and behind this patch. The Von Neumann neighborhood does not include diagonal patches.

> Due to performance concerns, if you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.

`get-color`

> Returns the color of the patch.

`get-index-vector`

> Returns the x, y and z indices of this patch as a vector.

`get-location`

> Returns the location of the patch.

`get-moore-neighborhood with-size neighborhoodSize = 1 (int)`

> Returns a list of the 2D Moore neighbors of this patch. The 2D Moore neighbors are the patches adjacent to this patch, including diagonally, on the X/Y plane.

> Due to performance concerns, if you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.

`get-patch with-offset indexOffset (vector)`

> Returns the patch at location indexOffset relative to this patch.

`get-patch-to-left`

> Returns the patch towards (-1, 0, 0).

`get-transparency`

> Returns the transparency value of the patch.

`get-von-neumann-neighborhood with-size neighborhoodSize = 1 (int)`

> Returns a list of the 2D Von Neumann neighbors of this patch. The 2D Von Neumann neighbors are the neighboring patches located left, right, above and below this patch on the X/Y plane. The Von Neumann neighborhood does not include diagonal patches.

> Due to performance concerns, if you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.

`get-x-index`

> Returns the x index of the patch.

`get-y-index`

> Returns the y index of the patch.

`get-z-index`

> Returns the z index of the patch.

`init-patch`

> This method does nothing in its default implementation. You can implement your own init-patch method in your patch class in order to perform initialization on the patch. This method is called after all the neighbor objects have been created--if you do initialization in the init method, the neighbors will not be initialized.

`set-color to newColor (vector)`

> Sets the color of the patch to newColor. Bear in mind that you'll also need to set the transparency of the patch if you want the patch to be displayed. See the method set-transparency for more information.

`set-transparency to alphaValue (float)`

> Sets the transparency of the patch to alphaValue. alphaValue is a number between 0.0 (fully transparent) and 1.0 (fully opaque). The default value is 0.5, semi-transparent.

Documentation created Fri Aug 8 15:16:49 2008