|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Hexagonal lattice with axial / offset / cube coordinate conversions and a TikZ-compatible pixel mapping. More...
#include <array>#include <cmath>#include <cstddef>#include <ostream>#include <sstream>#include <string>#include <ah-errors.H>#include <ca-traits.H>#include <tpl_ca_concepts.H>#include <tpl_ca_lattice.H>Go to the source code of this file.
Classes | |
| struct | Aleph::CA::Hex_Axial |
Axial integer coordinates (q, r) of a hex cell. More... | |
| struct | Aleph::CA::Hex_Offset |
Offset coordinates (col, row) for visualisation. More... | |
| struct | Aleph::CA::Hex_Cube |
Cube coordinates (x, y, z) with the constraint x+y+z = 0. More... | |
| class | Aleph::CA::Hex_Lattice< Storage, Boundary > |
| Hexagonal lattice with axial accessors over a 2D storage. More... | |
Namespaces | |
| namespace | Aleph |
| Main namespace for Aleph-w library functions. | |
| namespace | Aleph::CA |
Functions | |
| constexpr Hex_Offset | Aleph::CA::axial_to_offset_even_r (Hex_Axial a) noexcept |
| Axial -> offset (even-r convention: even rows are shifted right). | |
| constexpr Hex_Axial | Aleph::CA::offset_to_axial_even_r (Hex_Offset o) noexcept |
| Offset (even-r) -> axial. | |
| constexpr Hex_Offset | Aleph::CA::axial_to_offset_odd_r (Hex_Axial a) noexcept |
| Axial -> offset (odd-r convention: odd rows are shifted right). | |
| constexpr Hex_Axial | Aleph::CA::offset_to_axial_odd_r (Hex_Offset o) noexcept |
| Offset (odd-r) -> axial. | |
| constexpr Hex_Cube | Aleph::CA::axial_to_cube (Hex_Axial a) noexcept |
| Axial -> cube. | |
| constexpr Hex_Axial | Aleph::CA::cube_to_axial (Hex_Cube c) noexcept |
| Cube -> axial. | |
| constexpr ca_size_t | Aleph::CA::hex_distance (Hex_Axial a, Hex_Axial b) noexcept |
| Hex distance between two axial coordinates. | |
| std::array< double, 2 > | Aleph::CA::axial_to_pixel_pointy (Hex_Axial a, double radius) noexcept |
| Pointy-top pixel coordinates of an axial cell. | |
| std::array< double, 2 > | Aleph::CA::axial_to_pixel_flat (Hex_Axial a, double radius) noexcept |
| Flat-top pixel coordinates of an axial cell. | |
| template<typename Lattice , typename Palette > | |
| void | Aleph::CA::render_hex_lattice_tikz (std::ostream &os, const Lattice &lat, Palette &&palette, double radius=0.5, bool pointy_top=true) |
| Render a hex frame as a stand-alone TikZ picture. | |
| template<typename Lattice , typename Palette > | |
| std::string | Aleph::CA::render_hex_lattice_tikz (const Lattice &lat, Palette &&palette, double radius=0.5, bool pointy_top=true) |
Returns a std::string instead of writing to a stream. | |
Hexagonal lattice with axial / offset / cube coordinate conversions and a TikZ-compatible pixel mapping.
Hexagonal CAs are conventionally described in axial coordinates (q, r): two integer axes selected so that neighbour offsets are symmetric (six unit steps, including two diagonals). Storing the cells as a regular 2D row-major buffer indexed by (r, q) matches the rectangular bounding parallelogram of the hex grid; visualizers switch to offset coordinates (col, row) (even-r or odd-r) where alternate rows are shifted by half a hex.
This header does three things:
Hex_Axial, Hex_Offset, Hex_Cube value types and free functions to convert between them. All conversions are lossless and round-trip exactly for valid inputs.Hex_Lattice<Storage, Boundary>, a thin subclass of Lattice<Storage, Boundary> that adds axial/offset accessors and a hexagonal pixel mapping. The 2D rank is preserved, so the same Synchronous_Engine / Parallel_Synchronous_Engine and the existing Hex_Neighborhood (six axial offsets) work unchanged.render_hex_lattice_tikz to dump a frame as a TikZ picture for inclusion in reports / papers.Storage convention: coord c = {r, q}. Axis 0 stores r (axial row), axis 1 stores q (axial column). This matches the standard CA convention where axis 0 is the slowest-varying axis, and keeps the data layout cache-friendly for row-by-row iteration.
Definition in file tpl_ca_hex_lattice.H.