Coordinate Systems

Header: fiction/layouts/coordinates.hpp

Coordinate types identify positions in a coordinate system, e.g., a Cartesian or hexagonal grid. This file provides implementations for various types of coordinates.

Offset coordinates

An offset coordinate is a coordinate that defines a location via an offset from a fixed point (origin). Cartesian coordinates are offset coordinates.

struct ucoord_t

Unsigned offset coordinates.

This implementation is optimized for memory-efficiency and fits within 64 bits. Coordinates span from \((0, 0, 0)\) to \((2^{31} - 1, 2^{31} - 1, 1)\). Each coordinate has a dead indicator d that can be used to represent that it is not in use.

Cube coordinates

Cube coordinates are used as a way to identify faces in a hexagonal grid. A wonderful resource on the topic is: https://www.redblobgames.com/grids/hexagons/#coordinates-cube At the same time, they can be used to address 3-dimensional grids.

struct coord_t

Signed cube coordinates.

This implementation allows for negative coordinate values and offers a balance between memory consumption and range of values. Coordinates span from \((-2^{31}, -2^{31}, -2^{31})\) to \((2^{31} - 1, 2^{31} - 1, 2^{31} - 1)\). Each coordinate has a dead indicator d that can be used to represent that it is not in use.

SiQAD coordinates

SiQAD coordinates are used to describe locations of Silicon Dangling Bonds on the H-Si(100) 2x1 surface were dimer columns and rows are identified by x and y values, respectively, while the z value (0,1) points to the top or bottom Si atom in the dimer. The coordinates are originally used in the SiQAD simulator (https://github.com/siqad).

struct coord_t

SiQAD coordinates.

Coordinates span from \((-2^{31}, -2^{31}, 0)\) to \((2^{31} - 1 , 2^{31} - 1, 1)\). x is the SiDB’s x-coordinate, y is the dimer pair’s row number, and z represents the two possible SiDB positions in one SiDB dimer pair. Each coordinate has a dead indicator d that can be used to represent that it is not in use.

Coordinate iterator

An iterator type that allows to enumerate coordinates in order within a boundary.

template<typename CoordinateType>
class coord_iterator

An iterator type that allows to enumerate coordinates in order within a boundary.

Template Parameters:

CoordinateType – Type of coordinate to enumerate.

Utility functions

template<typename CoordinateType>
uint64_t fiction::area(const CoordinateType &coord) noexcept

Computes the area of a given coordinate assuming its origin is (0, 0, 0). Calculates \((|x| + 1) \cdot (|y| + 1)\) by default. The exception is SiQAD coordinates, for which it computes \((|x| + 1) \cdot (2 \cdot |y| + |z| + 1)\).

Template Parameters:

CoordinateType – Coordinate type.

Parameters:

coord – Coordinate.

Returns:

Area of coord.

template<typename CoordinateType>
uint64_t fiction::volume(const CoordinateType &coord) noexcept

Computes the volume of a given coordinate assuming its origin is (0, 0, 0). Calculates \((|x| + 1) \cdot (|y| + 1) \cdot (|z| + 1)\) by default. For SiQAD coordinates, which are planar by definition, the area is returned.

Template Parameters:

CoordinateType – Coordinate type.

Parameters:

coord – Coordinate.

Returns:

Volume of coord.

template<typename CoordinateType>
constexpr CoordinateType fiction::siqad::to_fiction_coord(const siqad::coord_t &coord) noexcept

Converts SiQAD coordinates to other coordinates (offset, cube).

Template Parameters:

CoordinateType – The desired coordinate type.

Parameters:

coord – SiQAD coordinate to convert.

Returns:

Coordinate of type CoordinateType.

template<typename CoordinateType>
constexpr coord_t fiction::siqad::to_siqad_coord(const CoordinateType &coord) noexcept

Converts any coordinate type to SiQAD coordinates.

Template Parameters:

CoordinateType – Coordinate type to convert.

Parameters:

coord – Coordinate to convert.

Returns:

SiQAD coordinate representation of coord.