Description
Round zero-sum fractional hex cube coordinates and repair the largest rounding-error component to preserve zero sum; ties repair z then y under the documented strict comparisons.
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.
Round zero-sum fractional hex cube coordinates and repair the largest rounding-error component to preserve zero sum; ties repair z then y under the documented strict comparisons.
When to use this tool
Use this tool to round zero-sum fractional hex cube coordinates and repair the largest rounding-error component to preserve zero sum; ties repair z then y under the documented strict comparisons.
How to use the tool and how it works
- Enter cube using the field definitions below.
- Run the operation. Correct input errors before interpreting an output.
- Read result.cube. Use the ordering, boundary rules and absence conditions described below.
Round each fractional cube component with JavaScript Math.round, then restore a zero component sum by correcting one coordinate. Correct x only when its absolute rounding error is strictly greatest; otherwise correct y when its error exceeds z’s, and correct z in the remaining cases.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| cube | Three cube components [x, y, z] summing to zero; fractional values are accepted only by the rounding operation. | Dense list of at most 128 finite numbers; integer/shape constraints above also apply. |
| Output field | Interpretation |
|---|---|
| result | Object containing the named fields below. |
| result.cube | Resulting [x, y, z] cube coordinate with zero component sum. |
{
"input": {
"cube": [
0.6,
-0.2,
-0.4
]
},
"output": {
"result": {
"cube": [
1,
0,
-1
]
}
}
} Limitations and assumptions
- Input components must sum to zero within tolerance; this is not independent rounding of axial coordinates.
- 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
Similar or alternative tools
- Hex Cube Axis Reflection
Reflect integer hex cube coordinates across a named cube axis by swapping the other two components; preserves zero-sum coordinates.
- Hex Cube Line Coordinate List
Enumerate a bounded shortest hex cube line by linear interpolation and deterministic zero-sum rounding, including both endpoints; no obstacles or tie-randomization.