sHexGrid: Function to define a supra-hexagonal grid

Description Usage Arguments Value Note See Also Examples

View source: R/sHexGrid.r

Description

sHexGrid is supposed to define a supra-hexagonal map grid. A supra-hexagon is a giant hexagon, which seamlessly consists of smaller hexagons. Due to the symmetric nature, it can be uniquely determined by specifying the radius away from the grid centroid. This function takes input the grid radius (or the number of hexagons in the grid, but will be adjusted to meet the definition of supra-hexagon), and returns a list (see 'Value' below) containing: the grid radius, the total number of hexagons in the grid, the 2D coordinates of the grid centroid, the step for each hexogan away from the grid centroid, and the 2D coordinates of all hexagons in the grid.

Usage

1
sHexGrid(r = NULL, nHex = NULL)

Arguments

r

an integer specifying the radius in a supra-hexagonal grid

nHex

the number of input hexagons in the grid

Value

an object of class "sHex", a list with following components:

Note

The relationships among return values:

See Also

sPipeline

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# The supra-hexagonal grid is exactly determined by specifying the radius.
sHex <- sHexGrid(r=2)

# The grid is determined according to the number of input hexagons (after being adjusted).
# The return res$nHex is always no less than the input one.
# It ensures a supra-hexagonal grid is exactly formed.
sHex <- sHexGrid(nHex=12)

# Ignore input nHex if r is also given
sHex <- sHexGrid(r=3, nHex=100)

# By default, r=3 if no parameters are specified
sHex <- sHexGrid()

hfang-bristol/supraHex documentation built on May 24, 2021, 3:13 p.m.