Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::Hex_Neighborhood Class Reference

Six-neighbour hex pattern in axial coordinates over a 2D lattice. More...

#include <tpl_ca_neighborhood.H>

Collaboration diagram for Aleph::CA::Hex_Neighborhood:
[legend]

Public Types

using coord_type = Coord_Vec< 2 >
 Coordinate type accepted by for_each_offset.
 

Static Public Member Functions

static constexpr std::size_t radius () noexcept
 Return the radius of the neighborhood (always 1).
 
static constexpr std::size_t size () noexcept
 Return the number of neighbours (always 6).
 
template<typename F >
static constexpr void for_each_offset (const Coord_Vec< 2 > &center, F &&f)
 Apply a functor to each of the six hex offsets.
 

Static Public Attributes

static constexpr std::size_t rank_v = 2
 Lattice dimension.
 
static constexpr std::size_t radius_v = 1
 Chebyshev radius (always 1 for hex grids).
 
static constexpr std::size_t size_v = 6
 Number of neighbours (always 6).
 
static constexpr std::array< Offset_Vec< 2 >, 6 > offsets = {{{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, -1}, {-1, 1}}}
 The six axial-coordinate offsets of the hex neighborhood.
 

Detailed Description

Six-neighbour hex pattern in axial coordinates over a 2D lattice.

Axial coordinates encode a hexagonal grid using two integer axes (q, r). Each cell has six neighbours at offsets:

(+1, 0), (-1, 0), (0, +1), (0, -1), (+1, -1), (-1, +1)

The lattice itself is a regular 2D Lattice<Storage, Boundary>; hexagonal interpretation is purely a function of which offsets the rule consumes.

Definition at line 357 of file tpl_ca_neighborhood.H.

Member Typedef Documentation

◆ coord_type

Coordinate type accepted by for_each_offset.

Definition at line 367 of file tpl_ca_neighborhood.H.

Member Function Documentation

◆ for_each_offset()

template<typename F >
static constexpr void Aleph::CA::Hex_Neighborhood::for_each_offset ( const Coord_Vec< 2 > &  center,
F &&  f 
)
inlinestaticconstexpr

Apply a functor to each of the six hex offsets.

Template Parameters
Ffunctor type.
Parameters
[in]centerthe coordinate of the center cell (unused).
[in]ffunctor to apply to each Offset_Vec<2>.

Definition at line 395 of file tpl_ca_neighborhood.H.

References Aleph::blossom_maximum_cardinality_matching(), and offsets.

◆ radius()

static constexpr std::size_t Aleph::CA::Hex_Neighborhood::radius ( )
inlinestaticconstexprnoexcept

Return the radius of the neighborhood (always 1).

Returns
1.

Definition at line 376 of file tpl_ca_neighborhood.H.

◆ size()

static constexpr std::size_t Aleph::CA::Hex_Neighborhood::size ( )
inlinestaticconstexprnoexcept

Return the number of neighbours (always 6).

Returns
6.

Definition at line 384 of file tpl_ca_neighborhood.H.

Member Data Documentation

◆ offsets

constexpr std::array<Offset_Vec<2>, 6> Aleph::CA::Hex_Neighborhood::offsets = {{{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, -1}, {-1, 1}}}
staticconstexpr

The six axial-coordinate offsets of the hex neighborhood.

Definition at line 370 of file tpl_ca_neighborhood.H.

Referenced by for_each_offset(), and TEST().

◆ radius_v

constexpr std::size_t Aleph::CA::Hex_Neighborhood::radius_v = 1
staticconstexpr

Chebyshev radius (always 1 for hex grids).

Definition at line 363 of file tpl_ca_neighborhood.H.

◆ rank_v

constexpr std::size_t Aleph::CA::Hex_Neighborhood::rank_v = 2
staticconstexpr

Lattice dimension.

Definition at line 361 of file tpl_ca_neighborhood.H.

◆ size_v

constexpr std::size_t Aleph::CA::Hex_Neighborhood::size_v = 6
staticconstexpr

Number of neighbours (always 6).

Definition at line 365 of file tpl_ca_neighborhood.H.


The documentation for this class was generated from the following file: