neighbourIndices: Compute coordinates of neighbours of hexmatrix cells

Description Usage Arguments Value

View source: R/neighbourIndices.R

Description

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.

Usage

1
neighbourIndices(indices, m)

Arguments

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.

Value

An array with:

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.


beerda/hexmatrix documentation built on May 2, 2021, 4:15 a.m.