• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

  • KGrid2D
  • Hexagonal
Public Member Functions | List of all members
KGrid2D::Hexagonal< Type > Class Template Reference

#include <kgrid2d.h>

Inheritance diagram for KGrid2D::Hexagonal< Type >:
KGrid2D::Generic< Type > KGrid2D::HexagonalBase

Public Member Functions

 Hexagonal (uint width=0, uint height=0)
 
CoordList neighbours (const Coord &c, bool insideOnly=true) const
 
CoordList neighbours (const Coord &c, uint distance, bool all, bool insideOnly=true) const
 
- Public Member Functions inherited from KGrid2D::Generic< Type >
 Generic (uint width=0, uint height=0)
 
void resize (uint width, uint height)
 
void fill (const Type &value)
 
uint width () const
 
uint height () const
 
uint size () const
 
uint index (const Coord &c) const
 
Coord coord (uint index) const
 
const Type & at (const Coord &c) const
 
Type & at (const Coord &c)
 
const Type & operator[] (const Coord &c) const
 
Type & operator[] (const Coord &c)
 
const Type & at (uint index) const
 
Type & at (uint index)
 
const Type & operator[] (uint index) const
 
Type & operator[] (uint index)
 
bool inside (const Coord &c) const
 
void bound (Coord &c) const
 

Additional Inherited Members

- Public Types inherited from KGrid2D::HexagonalBase
enum  Neighbour {
  Left = 0 , Right , LeftUp , LeftDown ,
  RightUp , RightDown , Nb_Neighbour
}
 
- Static Public Member Functions inherited from KGrid2D::HexagonalBase
static double angle (Neighbour n)
 
static Neighbour opposed (Neighbour n)
 
static Coord neighbour (const Coord &c, Neighbour n)
 
static uint distance (const Coord &c1, const Coord &c2)
 
- Protected Attributes inherited from KGrid2D::Generic< Type >
uint _width
 
uint _height
 
TQValueVector< Type > _vector
 

Detailed Description

template<class Type>
class KGrid2D::Hexagonal< Type >

This template implements a hexagonal grid where hexagons form horizontal lines:

(0,0)   (0,1)   (0,2)
    (1,0)   (1,1)   (1,2)
(2,0)   (2,1)   (2,2)

@ since 3.2

Definition at line 451 of file kgrid2d.h.

Constructor & Destructor Documentation

◆ Hexagonal()

template<class Type >
KGrid2D::Hexagonal< Type >::Hexagonal ( uint  width = 0,
uint  height = 0 
)
inline

Constructor.

Definition at line 457 of file kgrid2d.h.

Member Function Documentation

◆ neighbours() [1/2]

template<class Type >
CoordList KGrid2D::Hexagonal< Type >::neighbours ( const Coord &  c,
bool  insideOnly = true 
) const
inline
Returns
the neighbours of coordinate
Parameters
cto the given set of coordinates
cthe coordiante to use as the reference point
insideOnlyonly add coordinates that are inside the grid.

Definition at line 466 of file kgrid2d.h.

◆ neighbours() [2/2]

template<class Type >
CoordList KGrid2D::Hexagonal< Type >::neighbours ( const Coord &  c,
uint  distance,
bool  all,
bool  insideOnly = true 
) const
inline
Returns
the neighbours at distance
Parameters
distanceof coordinate
cthe coordinate to use as the reference point
distancedistance to the neighbour (1 means at contact).
insideOnlyonly add coordinates that are inside the grid.
allreturns all neighbours at distance equal and less than
distance(the original coordinate is not included).

Definition at line 485 of file kgrid2d.h.


The documentation for this class was generated from the following file:
  • kgrid2d.h

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.9.1
This website is maintained by Timothy Pearson.