oppositeDir: Compute opposite direction number

Description Usage Arguments Details Value

View source: R/oppositeDir.R

Description

In hexmatrix package, the directions of neighbours of a cell in a hexmatrix are numbered from 1 to 7 in clock-wise direction starting from top-left. That is, number 1 refers to the top-left neighbour, 2 is for top-right neighbour, 3 for right, 4 for bottom-right, 5 for bottom-left and 6 for left neighbour. Number 7 in some cases represents no-movement, i.e., the neighbour of a cell in the 7th direction is the cell itself.

Usage

1

Arguments

dir

A direction number (from 1 to 7)

Details

This function provides reverse numbering for such directions, i.e., a top-left neighbour (i.e., in direction 1) of a cell has this cell in bottom-right direction 4. etc.

Value

The opposite direction number, i.e. 4 for 1, 5 for 2, 6 for 3, 1 for 4, 2 for 5, 3 for 6 and 7 for 7.


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