Description Usage Arguments Value
View source: R/neighbourIndices.R
For each given coordinate of a cell (row, col), this function computes the coordinates of the neighbouring cells in all six directions starting clock-wisely from upper-left.
1 | neighbourIndices(indices, m)
|
indices |
A vector or matrix of coordinates, whose neighbour coordinates have to be computed. This argument has to be either a two-column matrix or a vector. If vector is provided, it is internally transformed into the two-column matrix. The columns represent row and column coordinates, respectively. |
m |
A hexmatrix or hexarray, for which the neighbour coordinates have to be obtained. |
An array with:
1st dimension corresponding to the input coordinates (i.e., to the rows
of the indices
matrix),
2nd dimension corresponding to the direction (1 to 6) of the neighbourhood (where 1 corresponds to the top-left neighbour and the rest of neighbours are assigned clock-wisely so that 2 corresponds to top-right, 3 to right, 4 to bottom-right, 5 to bottom-left and 6 to left),
3rd dimension is always of size 2 and represents rows (1) and columns (2) of the resulting coordinates.
For instance, if a single pair of values is put into indices
, i.e. row
and column of a cell, the resulting array would have dimensions (1, 6, 2)
for single input coordinate, 6 directions, 2 coordinates of the results.
The row & column number of the top-left neighbour is in [1, 1, 1:2]
of the result. The row & column number of the bottom-left neighbour is in
[1, 5, 1:2]
etc.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.