sHexGrid: Function to define a supra-hexagonal grid

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

a list with following components:

Note

The relationships among return values:

See Also

sTopology

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.
res <- 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.
res <- sHexGrid(nHex=12)

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

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

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.