cns_findwithin

Finds a range of indices of other cells that are within a certain radius of a given cell in common coordinate space along a particular dimension.

Syntax

[v1 v2]          = cns_findwithin(m, z, dim, c, pz, r)
[v1 v2 ok]       = cns_findwithin(m, z, dim, c, pz, r)
[v1 v2 c1 c2]    = cns_findwithin(m, z, dim, c, pz, r)
[v1 v2 c1 c2 ok] = cns_findwithin(m, z, dim, c, pz, r)
m
A model structure.

z
The layer number of the given cell.

dim
The dimension name, or its number in layer z.

c
Index (along this dimension) of the given cell in layer z.

pz
Layer number in which we are searching for cells.

r
The radius within which we are searching for cells. Expressed in units of the common coordinate space along this dimension. A floating point value.

v1, v2
Range of indices of the found cells along this dimension in layer pz. These are guaranteed to be valid indices, i.e., between 1 and the dimension size. The range may be empty.

c1, c2
These are the same as v1 and v2 except they are not guaranteed to be valid -- they can be less than 1 or greater than the dimension size. (This usually happens close to an edge.) Essentially, these are the indices that correspond to the search we performed, but they are not necessarily the indices of actual cells.

ok
When only v1 and v2 are returned, ok is true iff (v1 == c1) and (v2 == c2). When both ranges are returned, ok is true iff the range (v1 - v2) is not empty.

Notes

The equivalent kernel macro is FIND_type_dim_WITHIN.