Table of Contents

Struct PointyHexPoint

Namespace
Gamelogic.Grids
Assembly
Assembly-CSharp.dll

Represents coordinates of the faces in a regular hexagonal lattice.The hexagons have the Pointy orientation.

[Version(1, 0, 0)]
[Serializable]
public struct PointyHexPoint : IGridPoint<PointyHexPoint>, IEquatable<PointyHexPoint>, IGridPoint, IVectorPoint<PointyHexPoint>, ISplicedVectorPoint<PointyHexPoint, PointyHexPoint>, IVertex<FlatTriPoint>
Implements
Inherited Members
Extension Methods

Constructors

PointyHexPoint(int, int)

Constructs a new PointyHexPoint with the given coordinates.

public PointyHexPoint(int x, int y)

Parameters

x int
y int

Fields

East

public static readonly PointyHexPoint East

Field Value

PointyHexPoint

EdgeDirections

public static readonly IEnumerable<PointyRhombPoint> EdgeDirections

Field Value

IEnumerable<PointyRhombPoint>

MainDirections

public static readonly IEnumerable<PointyHexPoint> MainDirections

Field Value

IEnumerable<PointyHexPoint>

NorthEast

public static readonly PointyHexPoint NorthEast

Field Value

PointyHexPoint

NorthWest

public static readonly PointyHexPoint NorthWest

Field Value

PointyHexPoint

SouthEast

public static readonly PointyHexPoint SouthEast

Field Value

PointyHexPoint

SouthWest

public static readonly PointyHexPoint SouthWest

Field Value

PointyHexPoint

VertexDirections

public static readonly IEnumerable<FlatTriPoint> VertexDirections

Field Value

IEnumerable<FlatTriPoint>

VertexFaceDirections

public static readonly IEnumerable<FlatTriPoint> VertexFaceDirections

Field Value

IEnumerable<FlatTriPoint>

West

public static readonly PointyHexPoint West

Field Value

PointyHexPoint

Zero

The zero point (0, 0).

public static readonly PointyHexPoint Zero

Field Value

PointyHexPoint

Properties

BasePoint

A Uniform point's base point is simply the point itself. Makes it easier to implement generic algorithms. Since version 1.1

public PointyHexPoint BasePoint { get; }

Property Value

PointyHexPoint

SpliceCount

For spliced grids, this is the number of slices for all points.

For Uniform grids, this is always 1.

public int SpliceCount { get; }

Property Value

int

SpliceIndex

For spliced grids, this is the index of the splice.

For Uniform grids, this is always 0.

public int SpliceIndex { get; }

Property Value

int

X

The x-coordinate of this point. This need to be in XML

public int X { get; }

Property Value

int

Y

The y-coordinate of this point.

public int Y { get; }

Property Value

int

Z

Gets the Z coordinate of the point. The Z-coordinate is redundant, but is used for convenience by some algorithms.The coordinates satisfy \f$x + y + z = 0\f$.

public int Z { get; }

Property Value

int

Methods

DistanceFrom(PointyHexPoint)

The lattice distance from this point to the other.

public int DistanceFrom(PointyHexPoint other)

Parameters

other PointyHexPoint

Returns

int

Div(PointyHexPoint)

Gives a new point that represents the first point divided by the second point component-wise. The division is integer division.

Since version 1.6 (Rect) Since version 1.7 (other)

public PointyHexPoint Div(PointyHexPoint otherPoint)

Parameters

otherPoint PointyHexPoint

Returns

PointyHexPoint

Dot(PointyHexPoint)

[Version(1, 7, 0)]
public int Dot(PointyHexPoint other)

Parameters

other PointyHexPoint

Returns

int

Equals(PointyHexPoint)

public bool Equals(PointyHexPoint other)

Parameters

other PointyHexPoint

Returns

bool

Equals(object)

public override bool Equals(object other)

Parameters

other object

Returns

bool

GetColor(int, int, int)

Gives a coloring of the grid such that if a point p has color k, then all points p + m[ux, 0] + n[vx, vy] have the same color for any integers a and b.

More information anout grid colorings: http://gamelogic.co.za/2013/12/18/what-are-grid-colorings/

Since version 1.7

public int GetColor(int ux, int vx, int vy)

Parameters

ux int
vx int
vy int

Returns

int

GetColor1_1()

Generates a coloring with the following pattern:

Light Blue corresponds to 0. Light Green corresponds to 1. Light Yellow corresponds to 2. Light Red corresponds to 3. Blue corresponds to 4. Green corresponds to 5. Yellow corresponds to 6.

public int GetColor1_1()

Returns

int

GetColor1_2()

Generates a coloring with the following pattern:

Light Blue corresponds to 0. Light Green corresponds to 1. Light Yellow corresponds to 2. Light Red corresponds to 3. Blue corresponds to 4. Green corresponds to 5. Yellow corresponds to 6.

public int GetColor1_2()

Returns

int

GetColor1_3()

Generates a coloring with the following pattern:

Light Blue corresponds to 0. Light Green corresponds to 1. Light Yellow corresponds to 2. Light Red corresponds to 3. Blue corresponds to 4. Green corresponds to 5. Yellow corresponds to 6.

public int GetColor1_3()

Returns

int

GetColor2_2()

Generates a coloring with the following pattern:

Light Blue corresponds to 0. Light Green corresponds to 1. Light Yellow corresponds to 2. Light Red corresponds to 3. Blue corresponds to 4. Green corresponds to 5. Yellow corresponds to 6.

public int GetColor2_2()

Returns

int

GetColor2_4()

Generates a coloring with the following pattern:

Light Blue corresponds to 0. Light Green corresponds to 1. Light Yellow corresponds to 2. Light Red corresponds to 3. Blue corresponds to 4. Green corresponds to 5. Yellow corresponds to 6.

public int GetColor2_4()

Returns

int

GetColor3_2()

Generates a coloring with the following pattern:

Light Blue corresponds to 0. Light Green corresponds to 1. Light Yellow corresponds to 2. Light Red corresponds to 3. Blue corresponds to 4. Green corresponds to 5. Yellow corresponds to 6.

public int GetColor3_2()

Returns

int

GetColor3_7()

Generates a coloring with the following pattern:

Light Blue corresponds to 0. Light Green corresponds to 1. Light Yellow corresponds to 2. Light Red corresponds to 3. Blue corresponds to 4. Green corresponds to 5. Yellow corresponds to 6.

public int GetColor3_7()

Returns

int

GetColor5_5()

Since version 1.7

public int GetColor5_5()

Returns

int

GetColor6()

Since version 1.7

public int GetColor6()

Returns

int

GetEdgeAnchor()

public PointyRhombPoint GetEdgeAnchor()

Returns

PointyRhombPoint

GetEdges()

public IEnumerable<PointyRhombPoint> GetEdges()

Returns

IEnumerable<PointyRhombPoint>

GetHashCode()

public override int GetHashCode()

Returns

int

GetNeighbors()

public IEnumerable<PointyHexPoint> GetNeighbors()

Returns

IEnumerable<PointyHexPoint>

GetVertexAnchor()

public FlatTriPoint GetVertexAnchor()

Returns

FlatTriPoint

GetVertexFaceAnchor()

public FlatTriPoint GetVertexFaceAnchor()

Returns

FlatTriPoint

GetVertexFaces()

Get the coordinates of the faces that corresponds to this point treated as a vertex.

public IEnumerable<FlatTriPoint> GetVertexFaces()

Returns

IEnumerable<FlatTriPoint>

GetVertices()

public IEnumerable<FlatTriPoint> GetVertices()

Returns

IEnumerable<FlatTriPoint>

IsEquivalentUnderTransformsAndTranslation(IEnumerable<PointyHexPoint>, IEnumerable<PointyHexPoint>)

public static bool IsEquivalentUnderTransformsAndTranslation(IEnumerable<PointyHexPoint> shape1, IEnumerable<PointyHexPoint> shape2)

Parameters

shape1 IEnumerable<PointyHexPoint>
shape2 IEnumerable<PointyHexPoint>

Returns

bool

IsInNegativeHalfPlaneX(int)

public bool IsInNegativeHalfPlaneX(int x0)

Parameters

x0 int

Returns

bool

IsInNegativeHalfPlaneY(int)

public bool IsInNegativeHalfPlaneY(int y0)

Parameters

y0 int

Returns

bool

IsInNegativeHalfPlaneZ(int)

public bool IsInNegativeHalfPlaneZ(int z0)

Parameters

z0 int

Returns

bool

IsInPositiveHalfPlaneX(int)

Whether this point is inside the half plane x >= x0.

see http://devmag.org.za/2013/08/31/geometry-with-hex-coordinates/

Since version 1.3

public bool IsInPositiveHalfPlaneX(int x0)

Parameters

x0 int

Returns

bool

IsInPositiveHalfPlaneY(int)

Whether this point is inside the half plane y >= x0.

see http://devmag.org.za/2013/08/31/geometry-with-hex-coordinates/

Since version 1.3

public bool IsInPositiveHalfPlaneY(int y0)

Parameters

y0 int

Returns

bool

IsInPositiveHalfPlaneZ(int)

Whether this point is inside the half plane z >= z0.

see http://devmag.org.za/2013/08/31/geometry-with-hex-coordinates/

Since version 1.3

public bool IsInPositiveHalfPlaneZ(int z0)

Parameters

z0 int

Returns

bool

IsInsideHexagon(PointyHexPoint, int)

Whether this point is in the hexagon with the given radius and given center.

A single point is considered a hexagon with zero radius.

see http://devmag.org.za/2013/08/31/geometry-with-hex-coordinates/

Since version 1.3

public bool IsInsideHexagon(PointyHexPoint center, int radius)

Parameters

center PointyHexPoint
radius int

Returns

bool

IsInsideHexagon(int)

Whether this point is in the hexagon with the given radius and center at the origin.

The origin is considered the hexagon with zero radius.

see http://devmag.org.za/2013/08/31/geometry-with-hex-coordinates/

Since version 1.3

public bool IsInsideHexagon(int radius)

Parameters

radius int

Returns

bool

IsInsidePolygon(int, int, int, int, int, int)

public bool IsInsidePolygon(int x0, int x1, int y0, int y1, int z0, int z1)

Parameters

x0 int
x1 int
y0 int
y1 int
z0 int
z1 int

Returns

bool

IsInsideTriangle(int, int, int)

public bool IsInsideTriangle(int x0, int y0, int z0)

Parameters

x0 int
y0 int
z0 int

Returns

bool

Magnitude()

The magnitude of a hex point is the hex-distance between the point and the origin. This notation makes using hex points useful to use as vectors.

public int Magnitude()

Returns

int

Mod(PointyHexPoint)

Gives a new point that represents the reminder when the first point is divided by the second point component-wise. The division is integer division.

Since version 1.6 (Rect) Since version 1.7 (other)

public PointyHexPoint Mod(PointyHexPoint otherPoint)

Parameters

otherPoint PointyHexPoint

Returns

PointyHexPoint

MoveBackBy(PointyHexPoint)

If a spliced vectors u and v has base vector B and index I

public PointyHexPoint MoveBackBy(PointyHexPoint translation)

Parameters

translation PointyHexPoint

Returns

PointyHexPoint

Remarks

new SplicedVector(u.B.Subtract(v.B), (SpliceCount + u.I - v.I) % SpliceCount))

MoveBy(PointyHexPoint)

If a spliced vectors u and v has base vector B and index I,

public PointyHexPoint MoveBy(PointyHexPoint translation)

Parameters

translation PointyHexPoint

Returns

PointyHexPoint

Remarks

This operation is the same as

new SplicedVector(u.B.Translate(v.B), (u.I + v.I) % SpliceCount))

Mul(PointyHexPoint)

Gives a new point that represents the first point multiplied by the second point component-wise.

Since version 1.6 (Rect) Since version 1.7 (other)

public PointyHexPoint Mul(PointyHexPoint otherPoint)

Parameters

otherPoint PointyHexPoint

Returns

PointyHexPoint

Negate()

Returns a new point with the vector component negated.

public PointyHexPoint Negate()

Returns

PointyHexPoint

Perp()

[Version(1, 10, 0)]
public PointyHexPoint Perp()

Returns

PointyHexPoint

PerpDot(PointyHexPoint)

[Version(1, 7, 0)]
public int PerpDot(PointyHexPoint other)

Parameters

other PointyHexPoint

Returns

int

PointFromVertexAnchor()

public FlatTriPoint PointFromVertexAnchor()

Returns

FlatTriPoint

ReflectAboutX()

public PointyHexPoint ReflectAboutX()

Returns

PointyHexPoint

ReflectAboutY()

public PointyHexPoint ReflectAboutY()

Returns

PointyHexPoint

Rotate120()

public PointyHexPoint Rotate120()

Returns

PointyHexPoint

Rotate120AndReflectAboutY()

public PointyHexPoint Rotate120AndReflectAboutY()

Returns

PointyHexPoint

Rotate180()

public PointyHexPoint Rotate180()

Returns

PointyHexPoint

Rotate180AndReflectAboutY()

public PointyHexPoint Rotate180AndReflectAboutY()

Returns

PointyHexPoint

Rotate240()

public PointyHexPoint Rotate240()

Returns

PointyHexPoint

Rotate240AndReflectAboutY()

public PointyHexPoint Rotate240AndReflectAboutY()

Returns

PointyHexPoint

Rotate300()

public PointyHexPoint Rotate300()

Returns

PointyHexPoint

Rotate300AndReflectAboutY()

public PointyHexPoint Rotate300AndReflectAboutY()

Returns

PointyHexPoint

Rotate60()

public PointyHexPoint Rotate60()

Returns

PointyHexPoint

Rotate60AndReflectAboutY()

public PointyHexPoint Rotate60AndReflectAboutY()

Returns

PointyHexPoint

ScaleDown(int)

Scales this vector by the given amount.

public PointyHexPoint ScaleDown(int r)

Parameters

r int

Returns

PointyHexPoint

Examples

v.ScaleUp(1)
v.ScaleUp(n) ==  v.ScaleUp(n - 1).Translate(v)

ScaleUp(int)

public PointyHexPoint ScaleUp(int r)

Parameters

r int

Returns

PointyHexPoint

Subtract(PointyHexPoint)

Subtracts the other point from this point, and returns the result.

public PointyHexPoint Subtract(PointyHexPoint other)

Parameters

other PointyHexPoint

Returns

PointyHexPoint

ToCanonicalPosition(IEnumerable<PointyHexPoint>)

public static IEnumerable<PointyHexPoint> ToCanonicalPosition(IEnumerable<PointyHexPoint> shape)

Parameters

shape IEnumerable<PointyHexPoint>

Returns

IEnumerable<PointyHexPoint>

ToString()

public override string ToString()

Returns

string

Translate(PointyHexPoint)

This is a norm defined on the point, such that p1.Difference(p2).Abs() is equal to p1.DistanceFrom(p2).

public PointyHexPoint Translate(PointyHexPoint translation)

Parameters

translation PointyHexPoint

Returns

PointyHexPoint

__GetColor__ReferenceImplementation(int, int, int)

Gives a coloring of the grid such that if a point p has color k, then all points p + m[ux, 0] + n[vx, vy] have the same color for any integers a and b.

More information anout grid colorings: http://gamelogic.co.za/2013/12/18/what-are-grid-colorings/

Since version 1.7

public int __GetColor__ReferenceImplementation(int ux, int vx, int vy)

Parameters

ux int
vx int
vy int

Returns

int

Operators

operator +(PointyHexPoint, PointyHexPoint)

public static PointyHexPoint operator +(PointyHexPoint point1, PointyHexPoint point2)

Parameters

point1 PointyHexPoint
point2 PointyHexPoint

Returns

PointyHexPoint

operator /(PointyHexPoint, PointyHexPoint)

public static PointyHexPoint operator /(PointyHexPoint point1, PointyHexPoint point2)

Parameters

point1 PointyHexPoint
point2 PointyHexPoint

Returns

PointyHexPoint

operator /(PointyHexPoint, int)

public static PointyHexPoint operator /(PointyHexPoint point, int n)

Parameters

point PointyHexPoint
n int

Returns

PointyHexPoint

operator ==(PointyHexPoint, PointyHexPoint)

public static bool operator ==(PointyHexPoint point1, PointyHexPoint point2)

Parameters

point1 PointyHexPoint
point2 PointyHexPoint

Returns

bool

operator !=(PointyHexPoint, PointyHexPoint)

public static bool operator !=(PointyHexPoint point1, PointyHexPoint point2)

Parameters

point1 PointyHexPoint
point2 PointyHexPoint

Returns

bool

operator %(PointyHexPoint, PointyHexPoint)

public static PointyHexPoint operator %(PointyHexPoint point1, PointyHexPoint point2)

Parameters

point1 PointyHexPoint
point2 PointyHexPoint

Returns

PointyHexPoint

operator *(PointyHexPoint, PointyHexPoint)

public static PointyHexPoint operator *(PointyHexPoint point1, PointyHexPoint point2)

Parameters

point1 PointyHexPoint
point2 PointyHexPoint

Returns

PointyHexPoint

operator *(PointyHexPoint, int)

public static PointyHexPoint operator *(PointyHexPoint point, int n)

Parameters

point PointyHexPoint
n int

Returns

PointyHexPoint

operator -(PointyHexPoint, PointyHexPoint)

public static PointyHexPoint operator -(PointyHexPoint point1, PointyHexPoint point2)

Parameters

point1 PointyHexPoint
point2 PointyHexPoint

Returns

PointyHexPoint

operator -(PointyHexPoint)

public static PointyHexPoint operator -(PointyHexPoint point)

Parameters

point PointyHexPoint

Returns

PointyHexPoint

operator +(PointyHexPoint)

public static PointyHexPoint operator +(PointyHexPoint point)

Parameters

point PointyHexPoint

Returns

PointyHexPoint