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

Methods to Initialize Patches

Changing the Appearence of Patches

Getting Groups of Neighbor Patches

Getting Specific Patch Neighbors

Getting Information About a PatchChemicals in the Patch


get-3d-moore-neighborhood

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

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

Returns a list of the 3D Von Neumann neighbors of this patch. The 3D Von Neumann neighborhood consists of the 6 patches directly adjacent to the faces of this patch, in three dimensions.

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

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

If you intend to use the neighborhood frequently, you should call this method once and keep a copy of the list.


get-patch-above

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


get-patch-below

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


get-patch-to-east

Assumes that the patches are being observed from an XZ-plane. Returns the patch towards (1, 0, 0).


get-patch-to-left

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


get-patch-to-lower-left

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


get-patch-to-lower-right

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


get-patch-to-north

Assumes that the patches are being observed from an XZ-plane. Returns the patch towards (0, 0, -1).


get-patch-to-right

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


get-patch-to-south

Assumes that the patches are being observed from an XZ-plane. Returns the patch towards (0, 0, 1).


get-patch-to-upper-left

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


get-patch-to-upper-right

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


get-patch-to-west

Assumes that the patches are being observed from an XZ-plane. Returns the patch towards (-1, 0, 0).


get-patch-towards-minus-x

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


get-patch-towards-minus-x-minus-y

returns the patch towards (-1, -1, 0)


get-patch-towards-minus-x-plus-y

returns the patch towards (-1, 1, 0)


get-patch-towards-minus-y

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


get-patch-towards-minus-z

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


get-patch-towards-plus-x

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


get-patch-towards-plus-x-minus-y

returns the patch towards (1, -1, 0)


get-patch-towards-plus-x-plus-y

returns the patch towards (1, 1, 0)


get-patch-towards-plus-y

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


get-patch-towards-plus-z

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


get-transparency

Returns the transparency value of the patch.


get-von-neumann-neighborhood

Returns a list of the 2D Von Neumann neighbors of this patch. The 2D Von Neumann neighbors are the 8 patches located above, below, to the left of and to the right of this patch on the X/Y plane.

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 Sun Oct 7 19:13:03 2007