Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_ca_triangular_lattice.H File Reference

Triangular lattice with up/down parity helpers and pixel mapping suitable for visualisation. More...

#include <array>
#include <cstddef>
#include <ostream>
#include <sstream>
#include <string>
#include <utility>
#include <ah-errors.H>
#include <ca-traits.H>
#include <tpl_ca_concepts.H>
#include <tpl_ca_lattice.H>
Include dependency graph for tpl_ca_triangular_lattice.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::CA::Tri_Coord
 Coordinates of a triangular cell as (i, j) integers. More...
 
class  Aleph::CA::Triangular_Lattice< Storage, Boundary >
 Triangular lattice with parity helpers over a 2D storage. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::CA
 

Functions

constexpr int Aleph::CA::tri_parity (const Tri_Coord &c) noexcept
 
constexpr bool Aleph::CA::tri_is_up (const Tri_Coord &c) noexcept
 
constexpr bool Aleph::CA::tri_is_down (const Tri_Coord &c) noexcept
 
std::array< double, 2 > Aleph::CA::tri_pixel_centre (const Tri_Coord &c, const double side) noexcept
 Cartesian centre of a triangle in (i, j) units.
 
template<typename Lattice , typename Palette >
void Aleph::CA::render_triangular_lattice_tikz (std::ostream &os, const Lattice &lat, Palette &&palette, const double side=1.0)
 Render a triangular frame as a TikZ picture.
 
template<typename Lattice , typename Palette >
std::string Aleph::CA::render_triangular_lattice_tikz (const Lattice &lat, Palette &&palette, double side=1.0)
 Returns a std::string instead of writing to a stream.
 

Detailed Description

Triangular lattice with up/down parity helpers and pixel mapping suitable for visualisation.

A triangular lattice tiles the plane with alternating "up" and "down" triangles. Storing the cells as a regular 2D buffer with axes (i, j) is the simplest layout: the parity (i + j) & 1 decides whether the cell at (i, j) is an up-triangle (parity 0) or a down-triangle (parity 1). The existing Triangular_Neighborhood enumerates the three edge-neighbours according to this parity, so the generic engine works unchanged.

This header provides:

  • Tri_Coord value type (with i, j axes and parity helper).
  • Triangular_Lattice<Storage, Boundary>: subclass of Lattice that adds parity- and pixel-aware accessors plus a TikZ-style pixel mapping for triangle centres.
  • tri_pixel_centre: cartesian centre of an up/down triangle based on (i, j).
Author
Leandro Rabindranath Leon

Definition in file tpl_ca_triangular_lattice.H.