Hexagonal Lattice

Written by Paul Bourke
December 1997, Updated February 2004

C libraries: hexlib.h, and hexlib.c


Of the three 2 dimensional shapes (equilateral triangle, rectangle, and hexagon) that can be used to tile the plane without holes, the hexagon is the most complex and has many interesting properties. In what follows, an indexing system will be described for a hexagonal tiling called a Spiral Honeycomb Mosaic (SHM). A SHM consists of groups of 7n hexagons (n > 0) called super-hexagons. It uses a base 7 numbering system for the hexagonal mesh, this is illustrated below for n = 1, 2, and 3.


An application has been developed to explore operations in SHM space. It is based upon X-Windows and OpenGL and is currently available for Mac OS-X and Linux (by request). Note that before running the Mac OS-X version check that X-Windows is running. Download: macosx.tar.gz


The interface is straightforward, to find out about any command line options type "hex -h". The left mouse button pans the image, the middle button rolls, and the right button presents a list of menu options. In order to position/rotate/scale the hexagon to the image see the image mapping dialog box. To experiment with SHM operations see the transformation dialog box.

>hex -h
Usage: hex [options]
     -h      this text (help)
     -i s    load input TGA file
     -v      verbose mode
Key commands
    -,+      zoom in/out
      r      reset
      w      write TGA image of window contents
   1..6      set resolution
    ESC      quit
Mouse buttons
   left      translate
 middle      rotate
  right      menus

Addition and Multiplication

The two basic arithmetic operations can be defined for the SMH, addition and multiplication. These operations act on the addresses of the SHM and result in translation (addition) and rotation/scaling (multiplication) when applied to images represented with the "pixels" of the SHM. The following two C snippets (HexAdd() and HexMul()) implement addition and multiplication. An important characteristics of the operations defined in this way is they are bijective, that is, it is a one to one mapping of each address. Every address (hexagonal pixel) maps uniquely to another address so that no information is lost.


Notes - Spirals

The curve through powers of 7 (10hex) is an equiangular spiral described by

r = a exp(b theta)

Where r is the radius and theta the angle to the x axis. For example, for the spiral through 1hex, 10hex, 100hex, 1000hex, ... the parameters a and b are

a = sqrt(3)
b = loge(sqrt(7)) / arctan(sqrt(3) / 2) = 1.3632084.

Since the angle in the above case is taken from the negative y (imaginary) axis, the curve would be traced by

x = - r sin(theta)
y = - r cos(theta)

The angle between each successive multiples of 10hex is arctan(sqrt(3) / 2) = 40.893395o, the ratio of two successive radii is sqrt(7) = 2.6457513.

Online SHM Calculator

Base Conversion

Base 7
Base 10

Base 7
Base 10

Base 7
Base 10
Other Functions

Base 7
Base 10
Square root(s)

Base 7
Base 10


Alexander, D. and Sheridan, P.
Proceedings Australian Neuroscience Society (1995)
Algebraic Geometric Model of the Receptive Fields Properties of the Macaque Striate Cortex.

Sheridan, P.
PhD Thesis, University of Technology, Sydney (1996)
Spiral Architecture for Machine Vision

Sheridan, P., Alexander, D.M.
Proceedings of Vision, Recognition, Action: Boston. (1997)
Invariant transformations on a space-variant hexagonal grid

Sheridan, P., Hintz, T., Alexander, D.
Image and Vision Computing, 18 (2000)
Pseudo-invariant image transformations on a hexagonal lattice