Hexagon directions

from Red Blob Games
21 Apr 2018

Hex grids have six primary directions. Look at the max of |x-y|, |y-z|, |z-x|, and it will tell you which wedge you’re in.

You can also construct six “diagonal” directions. Look at the max of |x|, |y|, |z|:

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, 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: