Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Struct: RT.Coordinates.Hex

Summary

Represents a tile in a 2D flat-topped hexagonal grid.

Remarks

Represents a hexagonal tile in a two-dimensional grid in which each tile is a hexagon with a flat top and bottom and two of its vertices pointing left and right. Each hex is represented as a pair of coordinates (Q, R), where an increasing Q coordinate moves down and right, while an increasing R coordinate moves down.

Constructors

Hex(int q, int r)
Constructor.

Instance methods

string
ConvertCoordinates(int sideLength)
Returns a string representing this hex tile’s position within a Hex.LargeHexagon(int, Hex) structure in a more human-intuitive (but mathematically unhelpful) format. The first coordinate identifies a column of hexes, counting from 1 on the far left of the grid. The second specifies the position of the hex within that column, counting from 1 at the top.
bool
Equals(Hex other)
  • Implements: IEquatable<Hex>.Equals(Hex)
Compares this hex tile to another for equality.
bool
Equals(object obj)
  • Overrides: object.Equals(object)
Refer to the documentation for object.Equals.
IEnumerable<Hex.Direction>
GetEdges(int sideLength)
Assuming a Hex.LargeHexagon(int, Hex) structure of side length sideLength, returns a collection specifying which edges of the structure the current hex tile is adjacent to. (see also remarks)
int
  • Overrides: object.GetHashCode()
Refer to the documentation for object.GetHashCode.
PointD[]
GetPolygon(double hexWidth)
Returns a polygon describing the shape and position of the current hex tile in 2D space.
Hex
Move(Hex.Direction dir, int amount = 1)
Returns the hex tile reached by moving in the specified direction.
Hex
Rotate(int rotation)
Rotates the current hex’s position within the grid about the center hex (0, 0) clockwise by the specified multiple of 60°.
string
  • Overrides: object.ToString()
Refer to the documentation for object.ToString.

Static methods

double
LargeHeight(int sideLength)
Returns the total height of a Hex.LargeHexagon(int, Hex) structure, assuming each hex tile’s width is 1.
IEnumerable<Hex>
LargeHexagon(int sideLength, Hex center = null)
Returns a collection of tiles that form a hexagon of the specified size and position.
IEnumerable<PointD>
LargeHexagonOutline(int sideLength, double hexWidth, double expand = 0)
Returns a series of points that describe the outline of a Hex.LargeHexagon(int, Hex) structure.
double
LargeWidth(int sideLength)
Returns the total width of a Hex.LargeHexagon(int, Hex) structure, assuming each hex tile’s width is 1.

Operators

Hex
operator+(Hex one, Hex two)
Adds two hexes (treating them as vectors).
bool
operator==(Hex one, Hex two)
Compares two Hex values for equality.
bool
operator!=(Hex one, Hex two)
Compares two Hex values for inequality.
Hex
operator*(Hex hex, int multiplier)
Multiplies a hex’s coordinates by a multiplier.
Hex
operator*(int multiplier, Hex hex)
Hex
operator-(Hex one, Hex two)
Subtracts a hex from another (treating them as vectors).

Instance properties

PointDReturns the center of the hex tile in 2D space.
int Calculates the number of steps required to move from the center hex (0, 0) to the current hex. (see also remarks)
IEnumerable<Link<Vertex>>Refer to the documentation for IHasSvgGeometry.Edges.
Hex Returns the hex tile which is equal to the current hex tile when mirrored about the X-axis (horizontal line going through the center hex (0, 0)).
IEnumerable<Hex> Returns a collection containing all of the current tile’s neighbors. (see also remarks)
intReturns the Q coordinate (see Hex remarks).
intReturns the R coordinate (see Hex remarks).
Vertex[]Returns the vertices along the perimeter of this Hex, going clockwise from the top-left.

Static fields

IEnumerable<Hex.Direction>Provides a collection of all hexagonal directions.
double The ratio of the height of a hex tile to its width. In other words, if the width of a hex tile is 1 (from the left-pointing vertex to the right-pointing vertex), this constant is equal to the height (from the top edge to the bottom edge). (see also remarks)

Nested types

Identifies a direction within a 2D hexagonal grid.
Describes a 2D grid of flat-topped hexagonal cells.
Describes a vertex (gridline intersection) in a hexagonal grid (Hex.Grid).