Nodes

Base module for the nodes of a polyhex

class polyhex.objects.nodes.HexagonCentre(hexagon: Hexagon, feature: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = 'placeholder')

Bases: Node

HexagonCentre class which represents the centre of an hexagon It is created using:

an hexagon (polyhex.Hexagon), a feature (ArrayLike)

__init__(hexagon: Hexagon, feature: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = 'placeholder')

Constructor of the HexagonCentre class

Notes

The constructor adds the following attributes to the Node class [x,y] : defined as the cartesian coordinates of the HexagonCentre spatial_key : defined as the hex coordinates of the HexagonCentre

Parameters:
  • hexagon (Hexagon) – Hexagon the HexagonCentre is the centre of.

  • feature (ArrayLike, optional) – Feature of the HexagonCentre

distance(other, kwd='euclidian')

Method to compute the distance between two HexagonCentre

Parameters:
  • other (_type_) – other HexagonCentre

  • kwd (str, optional) – Identifier of the distance. Defaults to “euclidian”.

Raises:

NotImplementedError – This method is currently only implemented for the euclidian distance.

Returns:

float distance value

Return type:

np.ndarray

class polyhex.objects.nodes.HexagonVertex(hexagon: Hexagon, index: int = 0, feature: str = 'placeholder')

Bases: Node

HexagonVertex class which represents the centre of an hexagon It is created using:

an hexagon (polyhex.Hexagon) the index of the vertex on the considered Hexagon a feature (ArrayLike)

It defines an extra feature_key attribute that combines the spatial and feature attributes of the HexagonVertex.

Note

Unlike HexagonCentre, vertices can spatially coincide hence they need more information to be distinguished from one another.

__init__(hexagon: Hexagon, index: int = 0, feature: str = 'placeholder')

Constructor of the HexagonVertex class

Notes

The constructor adds the following attributes to the Node class [x,y] : defined as the cartesian coordinates of the HexagonVertex spatial_key : defined as the cartesian coordinates of the HexagonVertex feature_key : combines the spatial and feature attributes of the HexagonVertex.

Parameters:
  • hexagon (Hexagon) – Hexagon the HexagonVertex is part of.

  • feature (ArrayLike, optional) – Feature of the HexagonVertex

  • index (int) – the index of the vertex in the considered Hexagon

distance(other, kwd='euclidian')

Method to compute the distance between two HexagonVertex

Parameters:
  • other (_type_) – other HexagonVertex

  • kwd (str, optional) – Identifier of the distance. Defaults to “euclidian”.

Raises:

NotImplementedError – This is currently not implemented for any distance but the euclidian.

Returns:

float distance value

Return type:

np.ndarray