Given a vector of cell IDs (cell.ids
) and a vector (blocks
),
which defines the number of blocks / cells per dimension, a list of all
combinations of (linearly) neighbouring cells around each element of
cell.ids
is returned.
findLinearNeighbours(cell.ids, blocks, diag = FALSE)
cell.ids | [ |
---|---|
blocks | [ |
diag | [ |
[list
of integer(3)
].
List of neighbours. Each list element stands for a combination of
predecessing, current and succeeding cell.
cell.ids = c(5, 84, 17, 23) blocks = c(5, 4, 7) # (1) Considering diagonal neighbours as well: findLinearNeighbours(cell.ids = cell.ids, blocks = blocks, diag = TRUE)#> [[1]] #> [1] 1 17 33 #> #> [[2]] #> [1] 2 17 32 #> #> [[3]] #> [1] 3 17 31 #> #> [[4]] #> [1] 13 17 21 #> #> [[5]] #> [1] 16 17 18 #> #> [[6]] #> [1] 2 23 44 #> #> [[7]] #> [1] 3 23 43 #> #> [[8]] #> [1] 4 23 42 #> #> [[9]] #> [1] 7 23 39 #> #> [[10]] #> [1] 8 23 38 #> #> [[11]] #> [1] 9 23 37 #> #> [[12]] #> [1] 17 23 29 #> #> [[13]] #> [1] 18 23 28 #> #> [[14]] #> [1] 19 23 27 #> #> [[15]] #> [1] 22 23 24 #> #> [[16]] #> [1] 58 84 110 #> #> [[17]] #> [1] 59 84 109 #> #> [[18]] #> [1] 60 84 108 #> #> [[19]] #> [1] 63 84 105 #> #> [[20]] #> [1] 64 84 104 #> #> [[21]] #> [1] 65 84 103 #> #> [[22]] #> [1] 68 84 100 #> #> [[23]] #> [1] 69 84 99 #> #> [[24]] #> [1] 70 84 98 #> #> [[25]] #> [1] 78 84 90 #> #> [[26]] #> [1] 79 84 89 #> #> [[27]] #> [1] 80 84 88 #> #> [[28]] #> [1] 83 84 85 #># (2) Only consider neighbours which are parellel to the axes: findLinearNeighbours(cell.ids = cell.ids, blocks = blocks)#> [[1]] #> [1] 83 84 85 #> #> [[2]] #> [1] 79 84 89 #> #> [[3]] #> [1] 64 84 104 #> #> [[4]] #> [1] 16 17 18 #> #> [[5]] #> [1] 22 23 24 #> #> [[6]] #> [1] 18 23 28 #> #> [[7]] #> [1] 3 23 43 #>