Hexagon directions

from Red Blob Games
21 Apr 2018
Choose axis labels:

Hex grids have six primary directions. Look at the max of |{{labels.s}}-{{labels.q}}|, |{{labels.r}}-{{labels.s}}|, |{{labels.q}}-{{labels.r}}|, and it will tell you which wedge you're in.

You can also construct six “diagonal” directions. Look at the max of |{{labels.q}}|, |{{labels.s}}|, |{{labels.r}}|:

In both cases, some hexes are on the boundary between two wedges. There will be a tie between two of the max() arguments.

Another way to compute the direction is to convert from hex to pixel and then use the arctangent, atan2(y, x).

Also see this stackoverflow answer[1], which includes an interactive demo.

Source code for the the diagrams on this page: directions.js

Email me at , or tweet to @redblobgames, or post a public comment: