Skip to content

Main content

Hex Axial Center to Pixel Record

Map supplied fractional axial hex coordinates to Cartesian pixel centers for explicit pointy/flat orientation, circumradius and origin; no geographic units.

Loading tool…

Description

Map supplied fractional axial hex coordinates to Cartesian pixel centers for explicit pointy/flat orientation, circumradius and origin; no geographic units.

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.

Map supplied fractional axial hex coordinates to Cartesian pixel centers for explicit pointy/flat orientation, circumradius and origin; no geographic units.

When to use this tool

Use this tool to map supplied fractional axial hex coordinates to Cartesian pixel centers for explicit pointy/flat orientation, circumradius and origin; no geographic units.

How to use the tool and how it works

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

For pointy tops, x = originX + size×√3×(q+r/2) and y = originY + size×3r/2. For flat tops, x = originX + size×3q/2 and y = originY + size×√3×(r+q/2). Fractional axial coordinates remain fractional positions.1

Input fieldMeaning and unitsAccepted input
qAxial q coordinate, integer except for pixel-center mapping.Finite number satisfying the stated comparisons.
rAxial r coordinate, integer except for pixel-center mapping.Finite number satisfying the stated comparisons.
sizePositive center-to-corner hex radius, in the same units as origin and output.Finite number satisfying the stated comparisons.
pointyTrue selects pointy tops; false selects flat tops.Boolean true or false.
originCartesian [x,y] origin in output coordinate units.Dense list of at most 128 finite numbers, subject to the stated integer/shape rules.
Output fieldInterpretation
resultObject containing the fields below.
result.pointCartesian [x,y] center in the size/origin units.
json
{
  "input": {
    "q": 0,
    "r": 0,
    "size": 2,
    "pointy": true,
    "origin": [
      3,
      4
    ]
  },
  "output": {
    "result": {
      "point": [
        3,
        4
      ]
    }
  }
}

Limitations and assumptions

  • size is a positive center-to-corner radius in the same units as origin and output; this operation does not round to a cell.
  • 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 Center to Pixel Record — tool.io

Similar or alternative tools

  • Hex Axial Direction Step Record

    Advance axial hex coordinates by an explicit signed count along one of six documented direction vectors; no board-boundary or path legality model.

  • Hex Axial Disk Coordinate List

    Enumerate axial hex disk cells center-first then increasing fixed-order rings; radius 0–6 yields at most 127 distinct cells.