How to use the hex grid distance and range calculator
- Pick the coordinate system your map uses: axial, cube or one of four offset layouts.
- Enter the two numbers for the first hex, and the two numbers for the second hex. Cube coordinates take three numbers each.
- Set a range to count the hexes around the first hex.
- Read the distance, the hexes on the line between the two, and both hexes in every other system.
Formula
Cube coordinates (x, y, z) have x + y + z = 0; axial uses x = q and z = r
Distance = largest of |dx|, |dy| and |dz| between two hexes in cube coordinates
Hexes within range n of a center = 3 n (n + 1) + 1; hexes exactly n away = 6 n
Line: step evenly in cube space from one end to the other and round each point to a hex
Offset layouts (odd-r, even-r, odd-q, even-q) shift every other row or column. The page first removes the shift to get cube coordinates, then works there.
A distance of 5, and a range of 2
In axial coordinates, (0, 0) to (3, -5) is 5 steps. The line passes through (1, -1), (1, -2), (2, -3) and (2, -4). Within a range of 2 there are 19 hexes, 12 of them exactly 2 away. The same hexes in odd-r offset coordinates are (0, 0) and (0, -5).
On an odd-r offset map, (1, 1) to (5, 4) is 5 steps, and in cube coordinates (1, -3, 2) to (-2, 1, 1) is 4 steps, with 37 hexes within a range of 3.
Choosing a coordinate system
Axial and cube coordinates make distances and lines easy to compute, so they are common inside game code. Offset coordinates match how a map is drawn on a grid, with each row or column shifted by half a hex. A pointy-topped map shifts rows (odd-r or even-r), and a flat-topped map shifts columns (odd-q or even-q). If a count looks wrong, check that you picked the layout that matches your map.
For the odds of tabletop dice see the dice pool calculator and the hit, wound and save calculator. Regular shapes are in the regular polygon calculator, and printable maps in the hexagon grid paper generator.
Lines on a hex grid
A straight line across hexes is not unique when it runs exactly along the edge between two hexes. The page nudges the start slightly so that it always picks the same hex, but a game may use another rule. If your game defines the line differently, use the distance and the range, which do not depend on the choice.
Assumptions and limits
- The grid is an unbounded plane of regular hexes, with no edges, walls or terrain costs.
- Whole-number coordinates only, from -100,000 to 100,000, and a range from 0 to 1,000.
- Cube coordinates must add to zero.
- The line listing shows at most 200 hexes, though the distance is always exact.
Frequently asked questions
How do I find the distance between two hexes?
Convert both to cube coordinates and take the largest of the differences in x, y and z. The page converts from any system for you.
What is the difference between axial and offset coordinates?
Axial coordinates follow the hex directions, so the grid looks slanted. Offset coordinates shift every other row or column so that the map looks like a rectangle.
How many hexes are within a range of n?
There are 3n(n + 1) + 1, counting the center. A range of 2 has 19 hexes and a range of 3 has 37.
Which offset layout should I choose?
Use odd-r or even-r for pointy-top hexes and odd-q or even-q for flat-top hexes. The odd or even says which rows or columns are shifted.