
A coordinate system class defining a two-dimensional polar grid. It assigns inward
, outward
, clockwise
, and counterclockwise
properties to patches, and moveInward()
, moveOutward()
, moveClockwise()
, and moveCounterclockwise()
methods to non-patch agents, and also defines distance and angle functions on a polar grid.
Patches are addressed by an θ,r
index, both int
s, where θ
is the number of the patch starting at north, and moving clockwise, and r
is the number of patches outward from the center. There will thus be θ
×r
patches. Coordinates are defined similarly, with the angle dimension ranging from 0 to θ
(patch coordinate), rather than 0 to 2π (angle coordinate).
This class subclasses PatchesRect
since it shares the quality that columns have equal length. It should not be initialized in user code; it is initialized automatically with model.spatial(geometry='polar')
.
Initialization Parameters
dim — tuple(int, int), required
The
θ,r
dimensions of the grid.θ
is the number of patches around;r
is the number of patches out.
Methods
Click a method name for more detailed documentation.
neighbors( patch, corners )
Defines the spatial network among the patches. This function is called automatically during spatial setup and should not be called by user code.
place( patch )
Organizes
Patch
objects internally. Takes a patch object when created bymodel.nUpdater()
, places it in the appropriate list, and assigns itsposition
property.
Object Properties
dim — tuple(int, int)
The
θ,r
dimensions of the grid.θ
is the number of patches around;r
is the number of patches out.boundaries — tuple(tuple(int,int), tuple(int,int))
A tuple of tuples with the maximum and minimum coordinates that agents can take, given the grid dimensions.
((xmin, xmax), (ymin, ymax))
.wrap — tuple(bool, bool)
Whether each axis wraps around at the boundary. Fixed to
(True, False)
in polar geometry, since agents can move continuously around but will not wrap from the edge to the center.
Static Properties
geometry — str
The name of the patch geometry, to be set by subclasses.
Initial value: ''
Notes and Examples