Class HexMath
Hexagon math helper class. Coordinate conversions and hexagon geometry calculations. Supports axial, cube and offset coordinates. Supports flat top and pointy top hexagons. Supports odd and even layouts.
Inherited Members
Namespace: Fwt.Core
Assembly: fwt.core.dll
Syntax
[BurstCompile]
public static class HexMath
Fields
Directions_Axial
All directions for axial coordinates
Declaration
public static readonly FixedArray8<int2> Directions_Axial
Field Value
| Type | Description |
|---|---|
| FixedArray8<int2> |
Directions_Cube
All directions for cube coordinates
Declaration
public static readonly FixedArray8<int3> Directions_Cube
Field Value
| Type | Description |
|---|---|
| FixedArray8<int3> |
Directions_Offset_Even_Flat
All directions for even layout flat top hexagons
Declaration
public static readonly FixedArray16<int2> Directions_Offset_Even_Flat
Field Value
| Type | Description |
|---|---|
| FixedArray16<int2> |
Directions_Offset_Even_Point
All directions for even layout pointy top hexagons
Declaration
public static readonly FixedArray16<int2> Directions_Offset_Even_Point
Field Value
| Type | Description |
|---|---|
| FixedArray16<int2> |
Directions_Offset_Odd_Flat
All directions for odd layout flat top hexagons
Declaration
public static readonly FixedArray16<int2> Directions_Offset_Odd_Flat
Field Value
| Type | Description |
|---|---|
| FixedArray16<int2> |
Directions_Offset_Odd_Point
All directions for odd layout pointy top hexagons
Declaration
public static readonly FixedArray16<int2> Directions_Offset_Odd_Point
Field Value
| Type | Description |
|---|---|
| FixedArray16<int2> |
Sqrt3
Square root of 3 (used for calculations with hexagons)
Declaration
public static readonly float Sqrt3
Field Value
| Type | Description |
|---|---|
| float |
Methods
AxialToCube(in int2)
Converts axial coordinates to cube coordinates
Declaration
public static int3 AxialToCube(in int2 axialCoord)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | axialCoord | Axial coordinate to be converted |
Returns
| Type | Description |
|---|---|
| int3 | Converted cube coordinate |
AxialToCube(in int2, out int3)
Converts axial coordinates to cube coordinates
Declaration
[BurstCompile]
public static void AxialToCube(in int2 axialCoord, out int3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | axialCoord | Axial coordinate to be converted |
| int3 | result |
AxialToPixel(in int2, in float, in HexRotations)
Converts axial coordinates to pixel coordinates (point in world)
Declaration
public static float2 AxialToPixel(in int2 axial, in float sideSize, in HexRotations hexRotation)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | axial | axial coordinate |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
Returns
| Type | Description |
|---|---|
| float2 | pixel coordinate (point in world) |
AxialToPixel(in int2, in float, in HexRotations, out float2)
Converts axial coordinates to pixel coordinates (point in world)
Declaration
[BurstCompile]
public static void AxialToPixel(in int2 axial, in float sideSize, in HexRotations hexRotation, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | axial | axial coordinate |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
| float2 | result |
AxialToPixel(in int2, in float, in bool)
Converts axial coordinates to pixel coordinates (point in world)
Declaration
public static float2 AxialToPixel(in int2 axial, in float sideSize, in bool isFlatTop)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | axial | axial coordinate |
| float | sideSize | side length (radius) of hexagon |
| bool | isFlatTop | true = flat top, false = point top |
Returns
| Type | Description |
|---|---|
| float2 | pixel coordinate (point in world) |
AxialToPixel(in int2, in float, in bool, out float2)
Converts axial coordinates to pixel coordinates (point in world)
Declaration
[BurstCompile]
public static void AxialToPixel(in int2 axial, in float sideSize, in bool isFlatTop, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | axial | axial coordinate |
| float | sideSize | side length (radius) of hexagon |
| bool | isFlatTop | true = flat top, false = point top |
| float2 | result |
CellCoordAdd_Cube(in int3, in int3)
Adds offset to the cell coordinates (cube coordinates)
Declaration
public static int3 CellCoordAdd_Cube(in int3 origin, in int3 offset)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | origin | origin cube coordinates |
| int3 | offset | target cube coordinates |
Returns
| Type | Description |
|---|---|
| int3 | cube coordinate |
CellCoordAdd_Cube(in int3, in int3, out int3)
Adds offset to the cell coordinates (cube coordinates)
Declaration
[BurstCompile]
public static void CellCoordAdd_Cube(in int3 origin, in int3 offset, out int3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | origin | origin cube coordinates |
| int3 | offset | target cube coordinates |
| int3 | result |
CubeToAxial(in int3)
Converts cube coordinates to axial coordinates
Declaration
public static int2 CubeToAxial(in int3 cubeCoord)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | cubeCoord | Cube coordinate to be converted |
Returns
| Type | Description |
|---|---|
| int2 | Converted axial coordinates |
CubeToAxial(in int3, out int2)
Converts cube coordinates to axial coordinates
Declaration
[BurstCompile]
public static void CubeToAxial(in int3 cubeCoord, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | cubeCoord | Cube coordinate to be converted |
| int2 | result |
CubeToOffset(in int3, in HexRotations, in HexLayouts)
Converts cube coordinates to offset coordinates
Declaration
public static int2 CubeToOffset(in int3 cubeCoord, in HexRotations hexRotation, in HexLayouts hexLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | cubeCoord | cube coordinate |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
| HexLayouts | hexLayout | layout of hexagons (odd/even) |
Returns
| Type | Description |
|---|---|
| int2 | offset coordinate |
CubeToOffset(in int3, in HexRotations, in HexLayouts, out int2)
Converts cube coordinates to offset coordinates
Declaration
[BurstCompile]
public static void CubeToOffset(in int3 cubeCoord, in HexRotations hexRotation, in HexLayouts hexLayout, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | cubeCoord | cube coordinate |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
| HexLayouts | hexLayout | layout of hexagons (odd/even) |
| int2 | result |
CubeToOffset(in int3, in bool, in bool)
Converts cube coordinates to offset coordinates
Declaration
public static int2 CubeToOffset(in int3 cubeCoord, in bool isFlatTop, in bool isOddLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | cubeCoord | Cube coordinate |
| bool | isFlatTop | if true - flat top, false - point top |
| bool | isOddLayout | true - odd layout, flase - even layout |
Returns
| Type | Description |
|---|---|
| int2 | offset coordinate |
CubeToOffset(in int3, in bool, in bool, out int2)
Converts cube coordinates to offset coordinates
Declaration
[BurstCompile]
public static void CubeToOffset(in int3 cubeCoord, in bool isFlatTop, in bool isOddLayout, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | cubeCoord | Cube coordinate |
| bool | isFlatTop | if true - flat top, false - point top |
| bool | isOddLayout | true - odd layout, flase - even layout |
| int2 | result |
CubeToPixel(in int3, in float, in HexRotations)
Converts cube coordinates to pixel coordinates (point in world)
Declaration
public static float2 CubeToPixel(in int3 cube, in float sideSize, in HexRotations hexRotation)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | cube | cube coordinate |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
Returns
| Type | Description |
|---|---|
| float2 | pixel coordinate (point in world) |
CubeToPixel(in int3, in float, in HexRotations, out float2)
Converts cube coordinates to pixel coordinates (point in world)
Declaration
[BurstCompile]
public static void CubeToPixel(in int3 cube, in float sideSize, in HexRotations hexRotation, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | cube | cube coordinate |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
| float2 | result |
DistanceBetweenCells_Axial(in int2, in int2)
Calculates distance between two cells in axial coordinates
Declaration
public static int DistanceBetweenCells_Axial(in int2 from_axial, in int2 to_axial)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | from_axial | origin axial coordinate |
| int2 | to_axial | target axial coordinate |
Returns
| Type | Description |
|---|---|
| int | Axial coordinate |
DistanceBetweenCells_Axial(in int2, in int2, out int)
Calculates distance between two cells in axial coordinates
Declaration
[BurstCompile]
public static void DistanceBetweenCells_Axial(in int2 from_axial, in int2 to_axial, out int result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | from_axial | origin axial coordinate |
| int2 | to_axial | target axial coordinate |
| int | result |
DistanceBetweenCells_Cube(in int3, in int3)
Calculates distance between two cells in cube coordinates
Declaration
public static int DistanceBetweenCells_Cube(in int3 from_cube, in int3 to_cube)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | from_cube | origin cube coordinate |
| int3 | to_cube | target cube coordinate |
Returns
| Type | Description |
|---|---|
| int | cube coordinate |
DistanceBetweenCells_Cube(in int3, in int3, out int)
Calculates distance between two cells in cube coordinates
Declaration
[BurstCompile]
public static void DistanceBetweenCells_Cube(in int3 from_cube, in int3 to_cube, out int result)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | from_cube | origin cube coordinate |
| int3 | to_cube | target cube coordinate |
| int | result |
DistanceBetweenCells_Offset(in int2, in int2, in HexRotations, in HexLayouts)
Calculates distance between two cells in offset coordinates
Declaration
public static int DistanceBetweenCells_Offset(in int2 from_offset, in int2 to_offset, in HexRotations hexRotation, in HexLayouts hexLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | from_offset | origin offset coordinate |
| int2 | to_offset | target offset coordinate |
| HexRotations | hexRotation | hexagon rotation (flat/point top) |
| HexLayouts | hexLayout | laout rotation (odd/even) |
Returns
| Type | Description |
|---|---|
| int | offset coordinate |
DistanceBetweenCells_Offset(in int2, in int2, in HexRotations, in HexLayouts, out int)
Calculates distance between two cells in offset coordinates
Declaration
[BurstCompile]
public static void DistanceBetweenCells_Offset(in int2 from_offset, in int2 to_offset, in HexRotations hexRotation, in HexLayouts hexLayout, out int result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | from_offset | origin offset coordinate |
| int2 | to_offset | target offset coordinate |
| HexRotations | hexRotation | hexagon rotation (flat/point top) |
| HexLayouts | hexLayout | laout rotation (odd/even) |
| int | result |
DistanceBetweenCells_Offset_F(in int2, in int2, in HexRotations, in HexLayouts)
Calculates distance between two cells in offset coordinates
Declaration
public static float DistanceBetweenCells_Offset_F(in int2 from_offset, in int2 to_offset, in HexRotations hexRotation, in HexLayouts hexLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | from_offset | origin offset coordinate |
| int2 | to_offset | target offset coordinate |
| HexRotations | hexRotation | hexagon rotation (point/flat top) |
| HexLayouts | hexLayout | laoyout rotation (odd/even) |
Returns
| Type | Description |
|---|---|
| float | offset coordinate |
DistanceBetweenCells_Offset_F(in int2, in int2, in HexRotations, in HexLayouts, out float)
Calculates distance between two cells in offset coordinates
Declaration
[BurstCompile]
public static void DistanceBetweenCells_Offset_F(in int2 from_offset, in int2 to_offset, in HexRotations hexRotation, in HexLayouts hexLayout, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | from_offset | origin offset coordinate |
| int2 | to_offset | target offset coordinate |
| HexRotations | hexRotation | hexagon rotation (point/flat top) |
| HexLayouts | hexLayout | laoyout rotation (odd/even) |
| float | result |
GetAdjacentCell_Axial(in int2, in int)
Returns adjacent cell for given cell and neighbour index
Declaration
public static int2 GetAdjacentCell_Axial(in int2 cell, in int neighbourIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | cell | axial coordinate of the cell to find neighbour for |
| int | neighbourIndex | index of neighbour (6 neighbors) |
Returns
| Type | Description |
|---|---|
| int2 | axial coordinate of the neighbour |
GetAdjacentCell_Axial(in int2, in int, out int2)
Returns adjacent cell for given cell and neighbour index
Declaration
[BurstCompile]
public static void GetAdjacentCell_Axial(in int2 cell, in int neighbourIndex, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | cell | axial coordinate of the cell to find neighbour for |
| int | neighbourIndex | index of neighbour (6 neighbors) |
| int2 | result |
GetAdjacentCell_Cube(in int3, in int)
Returns adjacent cell for given cell and neighbour index
Declaration
public static int3 GetAdjacentCell_Cube(in int3 cell, in int neighbourIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | cell | cube coordinate of the cell to find neighbour for |
| int | neighbourIndex | index of neighbour (6 neighbors) |
Returns
| Type | Description |
|---|---|
| int3 | cube coordinate of the neighbour |
GetAdjacentCell_Cube(in int3, in int, out int3)
Returns adjacent cell for given cell and neighbour index
Declaration
[BurstCompile]
public static void GetAdjacentCell_Cube(in int3 cell, in int neighbourIndex, out int3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | cell | cube coordinate of the cell to find neighbour for |
| int | neighbourIndex | index of neighbour (6 neighbors) |
| int3 | result |
GetAdjacentCell_Offset(in int2, in int, in HexRotations, in HexLayouts)
Returns adjacent cell for given cell and neighbour index
Declaration
public static int2 GetAdjacentCell_Offset(in int2 cell, in int neighbourIndex, in HexRotations hexRotation, in HexLayouts hexLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | cell | offset coordinate of the cell to get neighbour for |
| int | neighbourIndex | index of neighbour (6 neighbors) |
| HexRotations | hexRotation | hexagon rotation (point/flat top) |
| HexLayouts | hexLayout | layout of hexagons (odd/even) |
Returns
| Type | Description |
|---|---|
| int2 | offset coordinate of adjacent cell |
GetAdjacentCell_Offset(in int2, in int, in HexRotations, in HexLayouts, out int2)
Returns adjacent cell for given cell and neighbour index
Declaration
[BurstCompile]
public static void GetAdjacentCell_Offset(in int2 cell, in int neighbourIndex, in HexRotations hexRotation, in HexLayouts hexLayout, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | cell | offset coordinate of the cell to get neighbour for |
| int | neighbourIndex | index of neighbour (6 neighbors) |
| HexRotations | hexRotation | hexagon rotation (point/flat top) |
| HexLayouts | hexLayout | layout of hexagons (odd/even) |
| int2 | result |
GetAdjacentCell_Offset(in int2, in int, in bool, in bool)
Returns adjacent cell for given cell and neighbour index
Declaration
public static int2 GetAdjacentCell_Offset(in int2 cell, in int neighbourIndex, in bool isOddLayout, in bool isFlatTop)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | cell | offset coordinate of the cell to get neighbour for |
| int | neighbourIndex | index of neighbour (6 neighbors) |
| bool | isOddLayout | true = odd layout, false = even layout |
| bool | isFlatTop | true = flat top, false = point top |
Returns
| Type | Description |
|---|---|
| int2 | offset coordinate of adjacent cell |
GetAdjacentCell_Offset(in int2, in int, in bool, in bool, out int2)
Returns adjacent cell for given cell and neighbour index
Declaration
[BurstCompile]
public static void GetAdjacentCell_Offset(in int2 cell, in int neighbourIndex, in bool isOddLayout, in bool isFlatTop, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | cell | offset coordinate of the cell to get neighbour for |
| int | neighbourIndex | index of neighbour (6 neighbors) |
| bool | isOddLayout | true = odd layout, false = even layout |
| bool | isFlatTop | true = flat top, false = point top |
| int2 | result |
GetCellsRange_Axial(in int2, int, Allocator)
Creates a results list with given allocator, Calculates range and fills results list with them
Declaration
public static NativeList<int2> GetCellsRange_Axial(in int2 center, int rangeSize, Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | center | |
| int | rangeSize | |
| Allocator | allocator |
Returns
| Type | Description |
|---|---|
| NativeList<int2> | axial coordinate |
GetCellsRange_Axial(in int2, int, Allocator, out NativeList<int2>)
Creates a results list with given allocator, Calculates range and fills results list with them
Declaration
[BurstCompile]
public static void GetCellsRange_Axial(in int2 center, int rangeSize, Allocator allocator, out NativeList<int2> result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | center | |
| int | rangeSize | |
| Allocator | allocator | |
| NativeList<int2> | result |
GetCellsRange_Axial(in int2, int, NativeList<int2>)
Calculates range and fills given list with coordinates. Returns filled list
Declaration
public static NativeList<int2> GetCellsRange_Axial(in int2 center, int rangeSize, NativeList<int2> results)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | center | |
| int | rangeSize | |
| NativeList<int2> | results |
Returns
| Type | Description |
|---|---|
| NativeList<int2> | axial coordinate |
GetCellsRange_Axial(in int2, int, ref NativeList<int2>)
Calculates range and fills given list with coordinates. Returns filled list
Declaration
[BurstCompile]
public static void GetCellsRange_Axial(in int2 center, int rangeSize, ref NativeList<int2> results)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | center | |
| int | rangeSize | |
| NativeList<int2> | results |
GetCellsRange_Cube(in int3, int, Allocator)
Creates a results list with given allocator, Calculates range and fills results list with them
Declaration
public static NativeList<int3> GetCellsRange_Cube(in int3 center, int rangeSize, Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | center | |
| int | rangeSize | |
| Allocator | allocator |
Returns
| Type | Description |
|---|---|
| NativeList<int3> | cube coordinate |
GetCellsRange_Cube(in int3, int, Allocator, out NativeList<int3>)
Creates a results list with given allocator, Calculates range and fills results list with them
Declaration
[BurstCompile]
public static void GetCellsRange_Cube(in int3 center, int rangeSize, Allocator allocator, out NativeList<int3> result)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | center | |
| int | rangeSize | |
| Allocator | allocator | |
| NativeList<int3> | result |
GetCellsRange_Cube(in int3, int, NativeList<int3>)
Calculates range and fills given list with coordinates. Returns filled list
Declaration
public static NativeList<int3> GetCellsRange_Cube(in int3 center, int rangeSize, NativeList<int3> results)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | center | |
| int | rangeSize | |
| NativeList<int3> | results |
Returns
| Type | Description |
|---|---|
| NativeList<int3> | cube coordinate |
GetCellsRange_Cube(in int3, int, ref NativeList<int3>)
Calculates range and fills given list with coordinates. Returns filled list
Declaration
[BurstCompile]
public static void GetCellsRange_Cube(in int3 center, int rangeSize, ref NativeList<int3> results)
Parameters
| Type | Name | Description |
|---|---|---|
| int3 | center | |
| int | rangeSize | |
| NativeList<int3> | results |
GetCellsRange_Offset(in int2, int, in HexRotations, in HexLayouts, Allocator)
Creates a results list with given allocator, Calculates range and fills results list with them
Declaration
public static NativeList<int2> GetCellsRange_Offset(in int2 center, int rangeSize, in HexRotations hexRotation, in HexLayouts hexLayout, Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | center | |
| int | rangeSize | |
| HexRotations | hexRotation | |
| HexLayouts | hexLayout | |
| Allocator | allocator |
Returns
| Type | Description |
|---|---|
| NativeList<int2> | offset coordinate |
GetCellsRange_Offset(in int2, int, in HexRotations, in HexLayouts, Allocator, out NativeList<int2>)
Creates a results list with given allocator, Calculates range and fills results list with them
Declaration
[BurstCompile]
public static void GetCellsRange_Offset(in int2 center, int rangeSize, in HexRotations hexRotation, in HexLayouts hexLayout, Allocator allocator, out NativeList<int2> result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | center | |
| int | rangeSize | |
| HexRotations | hexRotation | |
| HexLayouts | hexLayout | |
| Allocator | allocator | |
| NativeList<int2> | result |
GetCellsRange_Offset(in int2, int, in HexRotations, in HexLayouts, NativeList<int2>)
Calculates range and fills given list with coordinates. Returns filled list
Declaration
public static NativeList<int2> GetCellsRange_Offset(in int2 center, int rangeSize, in HexRotations hexRotation, in HexLayouts hexLayout, NativeList<int2> results)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | center | |
| int | rangeSize | |
| HexRotations | hexRotation | |
| HexLayouts | hexLayout | |
| NativeList<int2> | results |
Returns
| Type | Description |
|---|---|
| NativeList<int2> | offset coordinate |
GetCellsRange_Offset(in int2, int, in HexRotations, in HexLayouts, ref NativeList<int2>)
Calculates range and fills given list with coordinates. Returns filled list
Declaration
[BurstCompile]
public static void GetCellsRange_Offset(in int2 center, int rangeSize, in HexRotations hexRotation, in HexLayouts hexLayout, ref NativeList<int2> results)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | center | |
| int | rangeSize | |
| HexRotations | hexRotation | |
| HexLayouts | hexLayout | |
| NativeList<int2> | results |
GetDirection_Axial(in int)
Returns direction for given cell and neighbour index
Declaration
public static int2 GetDirection_Axial(in int directionIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | directionIndex | index of neihbour to find direction towards (6 neigbours) |
Returns
| Type | Description |
|---|---|
| int2 | direction towards the adjacent cell |
GetDirection_Axial(in int, out int2)
Returns direction for given cell and neighbour index
Declaration
[BurstCompile]
public static void GetDirection_Axial(in int directionIndex, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int | directionIndex | index of neihbour to find direction towards (6 neigbours) |
| int2 | result |
GetDirection_Cube(in int)
Returns direction for given cell and neighbour index
Declaration
public static int3 GetDirection_Cube(in int directionIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | directionIndex | index of neighbour to find direction towards (6 neigbours) |
Returns
| Type | Description |
|---|---|
| int3 | cube coordinate |
GetDirection_Cube(in int, out int3)
Returns direction for given cell and neighbour index
Declaration
[BurstCompile]
public static void GetDirection_Cube(in int directionIndex, out int3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int | directionIndex | index of neighbour to find direction towards (6 neigbours) |
| int3 | result |
GetDirection_Offset(in int2, in int, in HexRotations, in HexLayouts)
Returns direction for given cell and neighbour index
Declaration
public static int2 GetDirection_Offset(in int2 cell, in int neighbourIndex, in HexRotations hexRotation, in HexLayouts hexLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | cell | offset coordinate of the cell to get neighbour for |
| int | neighbourIndex | index of neighbour (6 neighbors) |
| HexRotations | hexRotation | hexagon rotation (point/flat top) |
| HexLayouts | hexLayout | layout of hexagon (odd/even) |
Returns
| Type | Description |
|---|---|
| int2 | direction towards the adjacent cell |
GetDirection_Offset(in int2, in int, in HexRotations, in HexLayouts, out int2)
Returns direction for given cell and neighbour index
Declaration
[BurstCompile]
public static void GetDirection_Offset(in int2 cell, in int neighbourIndex, in HexRotations hexRotation, in HexLayouts hexLayout, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | cell | offset coordinate of the cell to get neighbour for |
| int | neighbourIndex | index of neighbour (6 neighbors) |
| HexRotations | hexRotation | hexagon rotation (point/flat top) |
| HexLayouts | hexLayout | layout of hexagon (odd/even) |
| int2 | result |
GetDirection_Offset(in int2, in int, in bool, in bool)
Returns direction for given cell and neighbour index
Declaration
public static int2 GetDirection_Offset(in int2 cell, in int neighbourIndex, in bool isOddLayout, in bool isFlatTop)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | cell | cell to find a direction from |
| int | neighbourIndex | index of neighbour to find a direction towards (6 neigbours) |
| bool | isOddLayout | true = odd layout, false = even layout |
| bool | isFlatTop | true = flat top, false = point top |
Returns
| Type | Description |
|---|---|
| int2 | direction towards the adjacent cell |
GetDirection_Offset(in int2, in int, in bool, in bool, out int2)
Returns direction for given cell and neighbour index
Declaration
[BurstCompile]
public static void GetDirection_Offset(in int2 cell, in int neighbourIndex, in bool isOddLayout, in bool isFlatTop, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | cell | cell to find a direction from |
| int | neighbourIndex | index of neighbour to find a direction towards (6 neigbours) |
| bool | isOddLayout | true = odd layout, false = even layout |
| bool | isFlatTop | true = flat top, false = point top |
| int2 | result |
GetHexGridSize(in float, in int2, in HexRotations)
Returns size of the rectangle for hexagon grid with given sideLength and hexCount
Declaration
public static float2 GetHexGridSize(in float sideLength, in int2 hexCount, in HexRotations hexRotation)
Parameters
| Type | Name | Description |
|---|---|---|
| float | sideLength | Side length (radius) of the hexagon |
| int2 | hexCount | Size of the grid of hexagons |
| HexRotations | hexRotation | hexagon rotation (point/flat top) |
Returns
| Type | Description |
|---|---|
| float2 | size of the hexagons grid |
GetHexGridSize(in float, in int2, in HexRotations, out float2)
Returns size of the rectangle for hexagon grid with given sideLength and hexCount
Declaration
[BurstCompile]
public static void GetHexGridSize(in float sideLength, in int2 hexCount, in HexRotations hexRotation, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float | sideLength | Side length (radius) of the hexagon |
| int2 | hexCount | Size of the grid of hexagons |
| HexRotations | hexRotation | hexagon rotation (point/flat top) |
| float2 | result |
GetHexGridSize(in float, in int2, in bool)
Returns size of the rectangle for hexagon grid with given sideLength and hexCount
Declaration
public static float2 GetHexGridSize(in float sideLength, in int2 hexCount, in bool isFlatTop)
Parameters
| Type | Name | Description |
|---|---|---|
| float | sideLength | Side length (radius) of the hexagon |
| int2 | hexCount | Size of the grid of hexagons |
| bool | isFlatTop | if true - flat top, false - point top |
Returns
| Type | Description |
|---|---|
| float2 | size of the hexagons grid |
GetHexGridSize(in float, in int2, in bool, out float2)
Returns size of the rectangle for hexagon grid with given sideLength and hexCount
Declaration
[BurstCompile]
public static void GetHexGridSize(in float sideLength, in int2 hexCount, in bool isFlatTop, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float | sideLength | Side length (radius) of the hexagon |
| int2 | hexCount | Size of the grid of hexagons |
| bool | isFlatTop | if true - flat top, false - point top |
| float2 | result |
GetHexagonSize(in float, in HexRotations)
Returns size of the rectangle for hexagon with provided sideLength
Declaration
public static float2 GetHexagonSize(in float sideLength, in HexRotations hexRotation)
Parameters
| Type | Name | Description |
|---|---|---|
| float | sideLength | Side length (radius) of the hexagon |
| HexRotations | hexRotation | Rotation of the hexagon (point/flat top) |
Returns
| Type | Description |
|---|---|
| float2 | Size of the hexagon |
GetHexagonSize(in float, in HexRotations, out float2)
Returns size of the rectangle for hexagon with provided sideLength
Declaration
[BurstCompile]
public static void GetHexagonSize(in float sideLength, in HexRotations hexRotation, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float | sideLength | Side length (radius) of the hexagon |
| HexRotations | hexRotation | Rotation of the hexagon (point/flat top) |
| float2 | result |
GetHexagonSize(in float, in bool)
Returns size of the rectangle for hexagon with gived sideLength
Declaration
public static float2 GetHexagonSize(in float sideLenght, in bool isFlatTop)
Parameters
| Type | Name | Description |
|---|---|---|
| float | sideLenght | |
| bool | isFlatTop |
Returns
| Type | Description |
|---|---|
| float2 | size of the hexagon |
GetHexagonSize(in float, in bool, out float2)
Returns size of the rectangle for hexagon with gived sideLength
Declaration
[BurstCompile]
public static void GetHexagonSize(in float sideLenght, in bool isFlatTop, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float | sideLenght | |
| bool | isFlatTop | |
| float2 | result |
HexCornerPosition(in float2, in float, in int, in HexRotations)
returns position of hexagon's corner of given index for flat top and pointy top hexagon orientation
Declaration
public static float2 HexCornerPosition(in float2 center, in float sideSize, in int cornerIndex, in HexRotations hexRotation)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | center | center of the hexagon |
| float | sideSize | size of the side of the hexagon |
| int | cornerIndex | every next corner adds 60 degrees from starting point |
| HexRotations | hexRotation | rotation of the hexagon (point/flat top) |
Returns
| Type | Description |
|---|---|
| float2 | corner position |
HexCornerPosition(in float2, in float, in int, in HexRotations, out float2)
returns position of hexagon's corner of given index for flat top and pointy top hexagon orientation
Declaration
[BurstCompile]
public static void HexCornerPosition(in float2 center, in float sideSize, in int cornerIndex, in HexRotations hexRotation, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | center | center of the hexagon |
| float | sideSize | size of the side of the hexagon |
| int | cornerIndex | every next corner adds 60 degrees from starting point |
| HexRotations | hexRotation | rotation of the hexagon (point/flat top) |
| float2 | result |
HexCornerPosition(in float2, in float, in int, in bool)
returns position of hexagon's corner of given index for flat top and pointy top hexagon orientation
Declaration
public static float2 HexCornerPosition(in float2 center, in float sideSize, in int cornerIndex, in bool isFlatTop)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | center | center of the hexagon |
| float | sideSize | size of the side of the hexagon |
| int | cornerIndex | every next corner adds 60 degrees from starting point |
| bool | isFlatTop | true - hexagon with flat top; false - hexagon with pointy top |
Returns
| Type | Description |
|---|---|
| float2 | corner position |
HexCornerPosition(in float2, in float, in int, in bool, out float2)
returns position of hexagon's corner of given index for flat top and pointy top hexagon orientation
Declaration
[BurstCompile]
public static void HexCornerPosition(in float2 center, in float sideSize, in int cornerIndex, in bool isFlatTop, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | center | center of the hexagon |
| float | sideSize | size of the side of the hexagon |
| int | cornerIndex | every next corner adds 60 degrees from starting point |
| bool | isFlatTop | true - hexagon with flat top; false - hexagon with pointy top |
| float2 | result |
HexCornerPosition(in float2, in float, in float)
Gives position for hexagon corner (point on circle around center) with given angle in radians
Declaration
public static float2 HexCornerPosition(in float2 center, in float size, in float angle_rad)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | center | center of the circle |
| float | size | radius of the circle |
| float | angle_rad | angle of the point in radians |
Returns
| Type | Description |
|---|---|
| float2 | corner position |
HexCornerPosition(in float2, in float, in float, out float2)
Gives position for hexagon corner (point on circle around center) with given angle in radians
Declaration
[BurstCompile]
public static void HexCornerPosition(in float2 center, in float size, in float angle_rad, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | center | center of the circle |
| float | size | radius of the circle |
| float | angle_rad | angle of the point in radians |
| float2 | result |
OffsetToAxial(in int2, in HexRotations, in HexLayouts)
Converts offset coordinates to axial coordinates
Declaration
public static int2 OffsetToAxial(in int2 offset, in HexRotations hexRotation, in HexLayouts hexLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | offset | offset coordinate |
| HexRotations | hexRotation | hexagon rotation (point/flat top) |
| HexLayouts | hexLayout |
Returns
| Type | Description |
|---|---|
| int2 | offset coordinate |
OffsetToAxial(in int2, in HexRotations, in HexLayouts, out int2)
Converts offset coordinates to axial coordinates
Declaration
[BurstCompile]
public static void OffsetToAxial(in int2 offset, in HexRotations hexRotation, in HexLayouts hexLayout, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | offset | offset coordinate |
| HexRotations | hexRotation | hexagon rotation (point/flat top) |
| HexLayouts | hexLayout | |
| int2 | result |
OffsetToAxial(in int2, in bool, in bool)
Converts offset coordinates to axial coordinates
Declaration
public static int2 OffsetToAxial(in int2 offset, in bool isFlatTop, in bool isOddLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | offset | |
| bool | isFlatTop | |
| bool | isOddLayout |
Returns
| Type | Description |
|---|---|
| int2 | offset coordinate |
OffsetToAxial(in int2, in bool, in bool, out int2)
Converts offset coordinates to axial coordinates
Declaration
[BurstCompile]
public static void OffsetToAxial(in int2 offset, in bool isFlatTop, in bool isOddLayout, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | offset | |
| bool | isFlatTop | |
| bool | isOddLayout | |
| int2 | result |
OffsetToCube(in int2, in HexRotations, in HexLayouts)
Converts offset coordinates to cube coordinates
Declaration
public static int3 OffsetToCube(in int2 offsetCoord, in HexRotations hexRotation, in HexLayouts hexLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | offsetCoord | offset coordinate |
| HexRotations | hexRotation | rotation of hexagons (point/flat top) |
| HexLayouts | hexLayout | layout of hexagons (odd/even) |
Returns
| Type | Description |
|---|---|
| int3 | cube coordinate |
OffsetToCube(in int2, in HexRotations, in HexLayouts, out int3)
Converts offset coordinates to cube coordinates
Declaration
[BurstCompile]
public static void OffsetToCube(in int2 offsetCoord, in HexRotations hexRotation, in HexLayouts hexLayout, out int3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | offsetCoord | offset coordinate |
| HexRotations | hexRotation | rotation of hexagons (point/flat top) |
| HexLayouts | hexLayout | layout of hexagons (odd/even) |
| int3 | result |
OffsetToCube(in int2, in bool, in bool)
Converts offset coordinates to cube coordinates
Declaration
public static int3 OffsetToCube(in int2 offsetCoord, in bool isFlatTop, in bool isOddLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | offsetCoord | offset coordinate |
| bool | isFlatTop | true = flat top, false = point top |
| bool | isOddLayout | true = odd layout, false = even layout |
Returns
| Type | Description |
|---|---|
| int3 | cube coordinate |
OffsetToCube(in int2, in bool, in bool, out int3)
Converts offset coordinates to cube coordinates
Declaration
public static void OffsetToCube(in int2 offsetCoord, in bool isFlatTop, in bool isOddLayout, out int3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | offsetCoord | offset coordinate |
| bool | isFlatTop | true = flat top, false = point top |
| bool | isOddLayout | true = odd layout, false = even layout |
| int3 | result |
OffsetToPixel(in int2, in float, in HexRotations, in HexLayouts)
Converts offset coordinates to pixel coordinates (point in world)
Declaration
public static float2 OffsetToPixel(in int2 offset, in float sideSize, in HexRotations hexRotation, in HexLayouts hexLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | offset | offset coordinate |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
| HexLayouts | hexLayout | layout of hexagon (odd/even) |
Returns
| Type | Description |
|---|---|
| float2 | pixel coordinate (point in world) |
OffsetToPixel(in int2, in float, in HexRotations, in HexLayouts, out float2)
Converts offset coordinates to pixel coordinates (point in world)
Declaration
[BurstCompile]
public static void OffsetToPixel(in int2 offset, in float sideSize, in HexRotations hexRotation, in HexLayouts hexLayout, out float2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| int2 | offset | offset coordinate |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
| HexLayouts | hexLayout | layout of hexagon (odd/even) |
| float2 | result |
PixelToAxial(in float2, in float, in HexRotations)
Converts pixel coordinates to axial coordinates
Declaration
public static int2 PixelToAxial(in float2 pixel, in float sideSize, in HexRotations hexRotation)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | pixel | pixel coordinate (point in the world) |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
Returns
| Type | Description |
|---|---|
| int2 | axial coordinate |
PixelToAxial(in float2, in float, in HexRotations, out int2)
Converts pixel coordinates to axial coordinates
Declaration
[BurstCompile]
public static void PixelToAxial(in float2 pixel, in float sideSize, in HexRotations hexRotation, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | pixel | pixel coordinate (point in the world) |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
| int2 | result |
PixelToAxial(in float2, in float, in bool)
Converts pixel coordinates to axial coordinates
Declaration
public static int2 PixelToAxial(in float2 pixel, in float sideSize, in bool isFlatTop)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | pixel | pixel coordinate (point in the world) |
| float | sideSize | side length (radius) of hexagon |
| bool | isFlatTop | true = flat top, false = point top |
Returns
| Type | Description |
|---|---|
| int2 | axial coordinate |
PixelToAxial(in float2, in float, in bool, out int2)
Converts pixel coordinates to axial coordinates
Declaration
[BurstCompile]
public static void PixelToAxial(in float2 pixel, in float sideSize, in bool isFlatTop, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | pixel | pixel coordinate (point in the world) |
| float | sideSize | side length (radius) of hexagon |
| bool | isFlatTop | true = flat top, false = point top |
| int2 | result |
PixelToCube(in float2, in float, in HexRotations)
Converts pixel coordinates to cube coordinates
Declaration
public static int3 PixelToCube(in float2 pixel, in float sideSize, in HexRotations hexRotation)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | pixel | pixel coordinate (point in the world) |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
Returns
| Type | Description |
|---|---|
| int3 | cube coordinate |
PixelToCube(in float2, in float, in HexRotations, out int3)
Converts pixel coordinates to cube coordinates
Declaration
[BurstCompile]
public static void PixelToCube(in float2 pixel, in float sideSize, in HexRotations hexRotation, out int3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | pixel | pixel coordinate (point in the world) |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
| int3 | result |
PixelToOffset(in float2, in float, in HexRotations, in HexLayouts)
Converts pixel coordinates to offset coordinates
Declaration
public static int2 PixelToOffset(in float2 pixel, in float sideSize, in HexRotations hexRotation, in HexLayouts hexLayout)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | pixel | pixel coordinate (point in the world) |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
| HexLayouts | hexLayout | layout of hexagons (odd/even) |
Returns
| Type | Description |
|---|---|
| int2 | offset coordinate |
PixelToOffset(in float2, in float, in HexRotations, in HexLayouts, out int2)
Converts pixel coordinates to offset coordinates
Declaration
[BurstCompile]
public static void PixelToOffset(in float2 pixel, in float sideSize, in HexRotations hexRotation, in HexLayouts hexLayout, out int2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float2 | pixel | pixel coordinate (point in the world) |
| float | sideSize | side length (radius) of hexagon |
| HexRotations | hexRotation | rotation of hexagon (point/flat top) |
| HexLayouts | hexLayout | layout of hexagons (odd/even) |
| int2 | result |