Skip to content

Main content

Hex Axial Ring Coordinate List

Enumerate one axial hex ring in a fixed six-direction walk; radius zero is the center and positive rings are bounded to 126 cells.

Loading tool…

Description

Enumerate one axial hex ring in a fixed six-direction walk; radius zero is the center and positive rings are bounded to 126 cells.

Hexagonal grids can store cells as axial [q,r], parity-based offset or doubled coordinates. Those integer layouts describe the same lattice with different row/column conventions. Drawing cell centers also needs an orientation, origin and center-to-corner radius; those drawing units are separate from lattice coordinates.

Enumerate one axial hex ring in a fixed six-direction walk; radius zero is the center and positive rings are bounded to 126 cells.

When to use this tool

Use this tool to enumerate one axial hex ring in a fixed six-direction walk; radius zero is the center and positive rings are bounded to 126 cells.

How to use the tool and how it works

  1. Enter q, r, radius using the input definitions below.
  2. Run the operation. Resolve malformed-input errors before interpreting the result.
  3. Read result.coordinates. Interpret signs, units, ordering and null values using the rules below.

At radius zero return the center alone. Otherwise start at [q−radius,r+radius] and walk radius steps in each direction [1,0], [1,−1], [0,−1], [−1,0], [−1,1], [0,1], recording each position before its step.1

Input fieldMeaning and unitsAccepted input
qAxial q coordinate, integer except for pixel-center mapping.Finite safe integer satisfying the stated bounds.
rAxial r coordinate, integer except for pixel-center mapping.Finite safe integer satisfying the stated bounds.
radiusNonnegative integer ring/disk radius in hex-cell steps; its operation-specific upper bound is stated above.Finite safe integer satisfying the stated bounds.
Output fieldInterpretation
resultObject containing the fields below.
result.coordinatesOrdered axial [q,r] cells in the explicit ring/disk traversal.
json
{
  "input": {
    "q": 0,
    "r": 0,
    "radius": 1
  },
  "output": {
    "result": {
      "coordinates": [
        [
          -1,
          1
        ],
        [
          0,
          1
        ],
        [
          1,
          0
        ],
        [
          1,
          -1
        ],
        [
          0,
          -1
        ],
        [
          -1,
          0
        ]
      ]
    }
  }
}

Limitations and assumptions

  • Radius is an integer 0–21; a positive ring has exactly 6×radius coordinates and does not include its center.
  • Integer lattice inputs are bounded to ±1,000,000,000; the pixel-center operation accepts fractional axial values. Ring/disk radius bounds are stated above. No geographic projection, physical scale or board boundary is inferred.
  • Every declared top-level input is required and unknown fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
  • Numeric outputs must be finite and within the absolute safe-integer magnitude; exact larger integers use decimal text. Source positions are zero-based UTF-16 offsets and span ends are exclusive unless a different convention is explicitly stated.

Alternative or Complementary methods

Keep grid layout, parity convention and drawing orientation consistent. Use coordinate conversion for an existing cell and a separate pathfinding model for obstacles or routes.

References

  1. Tool behavior and example: Hex Axial Ring Coordinate List — tool.io

Similar or alternative tools