Skip to content

Main content

Hex Pixel to Fractional Axial Record

Invert explicit hex-center pixel mapping to fractional axial coordinates without rounding to a cell; caller supplies orientation, circumradius and origin.

Loading tool…

Description

Invert explicit hex-center pixel mapping to fractional axial coordinates without rounding to a cell; caller supplies orientation, circumradius and origin.

Hexagonal grids can use axial, three-component cube or parity-based offset coordinates. Cube coordinates satisfy x + y + z = 0; axial coordinates use two components. Pixel layouts additionally need orientation, origin and center-to-corner size, which are separate from the integer coordinate convention.

Invert explicit hex-center pixel mapping to fractional axial coordinates without rounding to a cell; caller supplies orientation, circumradius and origin.

When to use this tool

Use this tool to invert explicit hex-center pixel mapping to fractional axial coordinates without rounding to a cell; caller supplies orientation, circumradius and origin.

How to use the tool and how it works

  1. Enter point, size, pointy, origin using the field definitions below.
  2. Run the operation. Correct input errors before interpreting an output.
  3. Read result.q, result.r. Use the ordering, boundary rules and absence conditions described below.

Subtract origin from the pixel point and invert the pointy- or flat-top axial layout formulas using the positive center-to-corner size.1

Input fieldMeaning and unitsAccepted input
pointPixel/world point [x, y], in the same units as origin and size.Dense list of at most 128 finite numbers; integer/shape constraints above also apply.
sizePositive center-to-corner radius, not edge-to-edge diameter.A finite number satisfying the operation’s stated comparisons.
pointyTrue selects pointy-top formulas; false selects flat-top formulas.A boolean true or false.
originPixel/world origin [x, y].Dense list of at most 128 finite numbers; integer/shape constraints above also apply.
Output fieldInterpretation
resultObject containing the named fields below.
result.qAxial q coordinate; fractional for the pixel inverse operation.
result.rAxial r coordinate; fractional for the pixel inverse operation.
json
{
  "input": {
    "point": [
      3,
      4
    ],
    "size": 2,
    "pointy": true,
    "origin": [
      3,
      4
    ]
  },
  "output": {
    "result": {
      "q": 0,
      "r": 0
    }
  }
}

Limitations and assumptions

  • The result is fractional q/r coordinates, not a selected cell; screen coordinates and size must share the same units.
  • Integer layout coordinates are bounded to ±1,000,000,000 where required. Cube components must sum to zero within 1e−8. Pixel coordinates, origin and size must use the same distance units; angular calculations use radians internally.
  • Every declared top-level input field is required and unexpected 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 no larger in absolute magnitude than the safe-integer limit; operations returning exact large integers use decimal text. Positions are zero-based and spans end exclusively unless the operation explicitly states a different convention.

Alternative or Complementary methods

Keep coordinate layout, parity convention and drawing orientation consistent. Use an explicit rounding operation to choose an integer cell from fractional coordinates and a separate pathfinding model for obstacles or routes.

References

  1. Tool behavior and example: Hex Pixel to Fractional Axial Record — tool.io

Similar or alternative tools

  • Hex Axial to Even Row Offset

    Convert signed integer hex coordinates between axial and even-row offset convention; floor-compatible parity handles negative coordinates, no geographic projection.

  • Hex Axial to Odd Column Offset

    Convert signed integer hex coordinates between axial and odd-column offset convention; floor-compatible parity handles negative coordinates, no geographic projection.