-
Notifications
You must be signed in to change notification settings - Fork 12
Octagonal tiles
Octagons can't tile a flat surface (there would be gaps in-between the tiles), but they can tile a hyperbolic plane, as illustrated below. (Alternatively, you can think of these as squares on a board game where diagonal moves are allowed.)

With the above image, it may be difficult to visualise an indexing scheme. I find it easier to visualise the tiles on a flat plane, with diamond-shaped "holes" in space. Two tiles on opposite sides of a "hole" are neighbours, just as are two tiles that share a common edge.
UnboundedOctGrid is an infinite, unbounded, grid filled with octagonal tiles.
The indexing scheme is illustrated below.

rectOctGrid r c returns a rectangular grid with r rows and c columns, using octagonal tiles.
Depending on whether the number of rows and columns is even or odd,
the centre of the grid may consist of one, two, or four tiles.
torOctGrid r c returns a toroidal grid with r rows and c columns, using octagonal tiles.
The indexing scheme is the same as for torRectGrid.
A toroidal grid has no boundary, and no defined centre.