Table of Contents

Struct FlatHexPoint

Namespace
Gamelogic.Grids
Assembly
Assembly-CSharp.dll

A point of a hexagonal grid, where the hexagons have two horizontal edges.

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

Constructors

FlatHexPoint(int, int)

Constructs a new FlatHexPoint with the given coordinates.

public FlatHexPoint(int x, int y)

Parameters

x int
y int

Fields

EdgeDirections

public static readonly IEnumerable<FlatRhombPoint> EdgeDirections

Field Value

IEnumerable<FlatRhombPoint>

MainDirections

public static readonly IEnumerable<FlatHexPoint> MainDirections

Field Value

IEnumerable<FlatHexPoint>

North

public static readonly FlatHexPoint North

Field Value

FlatHexPoint

NorthEast

public static readonly FlatHexPoint NorthEast

Field Value

FlatHexPoint

NorthWest

public static readonly FlatHexPoint NorthWest

Field Value

FlatHexPoint

South

public static readonly FlatHexPoint South

Field Value

FlatHexPoint

SouthEast

public static readonly FlatHexPoint SouthEast

Field Value

FlatHexPoint

SouthWest

public static readonly FlatHexPoint SouthWest

Field Value

FlatHexPoint

VertexDirections

public static readonly IEnumerable<PointyTriPoint> VertexDirections

Field Value

IEnumerable<PointyTriPoint>

VertexFaceDirections

public static readonly IEnumerable<PointyTriPoint> VertexFaceDirections

Field Value

IEnumerable<PointyTriPoint>

Zero

The zero point (0, 0).

public static readonly FlatHexPoint Zero

Field Value

FlatHexPoint

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 FlatHexPoint BasePoint { get; }

Property Value

FlatHexPoint

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 redundent, 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(FlatHexPoint)

The lattice distance from this point to the other.

public int DistanceFrom(FlatHexPoint other)

Parameters

other FlatHexPoint

Returns

int

Div(FlatHexPoint)

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 FlatHexPoint Div(FlatHexPoint otherPoint)

Parameters

otherPoint FlatHexPoint

Returns

FlatHexPoint

Dot(FlatHexPoint)

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

Parameters

other FlatHexPoint

Returns

int

Equals(FlatHexPoint)

public bool Equals(FlatHexPoint other)

Parameters

other FlatHexPoint

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 FlatRhombPoint GetEdgeAnchor()

Returns

FlatRhombPoint

GetEdges()

public IEnumerable<FlatRhombPoint> GetEdges()

Returns

IEnumerable<FlatRhombPoint>

GetHashCode()

public override int GetHashCode()

Returns

int

GetVertexAnchor()

public PointyTriPoint GetVertexAnchor()

Returns

PointyTriPoint

GetVertexFaceAnchor()

public PointyTriPoint GetVertexFaceAnchor()

Returns

PointyTriPoint

GetVertexFaces()

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

public IEnumerable<PointyTriPoint> GetVertexFaces()

Returns

IEnumerable<PointyTriPoint>

GetVertices()

public IEnumerable<PointyTriPoint> GetVertices()

Returns

IEnumerable<PointyTriPoint>

IsEquivalentUnderTransformsAndTranslation(IEnumerable<FlatHexPoint>, IEnumerable<FlatHexPoint>)

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

Parameters

shape1 IEnumerable<FlatHexPoint>
shape2 IEnumerable<FlatHexPoint>

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(FlatHexPoint, 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(FlatHexPoint center, int radius)

Parameters

center FlatHexPoint
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(FlatHexPoint)

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 FlatHexPoint Mod(FlatHexPoint otherPoint)

Parameters

otherPoint FlatHexPoint

Returns

FlatHexPoint

MoveBackBy(FlatHexPoint)

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

public FlatHexPoint MoveBackBy(FlatHexPoint translation)

Parameters

translation FlatHexPoint

Returns

FlatHexPoint

Remarks

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

MoveBy(FlatHexPoint)

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

public FlatHexPoint MoveBy(FlatHexPoint translation)

Parameters

translation FlatHexPoint

Returns

FlatHexPoint

Remarks

This operation is the same as

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

Mul(FlatHexPoint)

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 FlatHexPoint Mul(FlatHexPoint otherPoint)

Parameters

otherPoint FlatHexPoint

Returns

FlatHexPoint

Negate()

Returns a new point with the vector component negated.

public FlatHexPoint Negate()

Returns

FlatHexPoint

Perp()

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

Returns

FlatHexPoint

PerpDot(FlatHexPoint)

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

Parameters

other FlatHexPoint

Returns

int

PointFromVertexAnchor()

public PointyTriPoint PointFromVertexAnchor()

Returns

PointyTriPoint

ReflectAboutX()

public FlatHexPoint ReflectAboutX()

Returns

FlatHexPoint

ReflectAboutY()

public FlatHexPoint ReflectAboutY()

Returns

FlatHexPoint

Rotate120()

public FlatHexPoint Rotate120()

Returns

FlatHexPoint

Rotate120AndReflectAboutY()

public FlatHexPoint Rotate120AndReflectAboutY()

Returns

FlatHexPoint

Rotate180()

public FlatHexPoint Rotate180()

Returns

FlatHexPoint

Rotate180AndReflectAboutY()

public FlatHexPoint Rotate180AndReflectAboutY()

Returns

FlatHexPoint

Rotate240()

public FlatHexPoint Rotate240()

Returns

FlatHexPoint

Rotate240AndReflectAboutY()

public FlatHexPoint Rotate240AndReflectAboutY()

Returns

FlatHexPoint

Rotate300()

public FlatHexPoint Rotate300()

Returns

FlatHexPoint

Rotate300AndReflectAboutY()

public FlatHexPoint Rotate300AndReflectAboutY()

Returns

FlatHexPoint

Rotate60()

public FlatHexPoint Rotate60()

Returns

FlatHexPoint

Rotate60AndReflectAboutY()

public FlatHexPoint Rotate60AndReflectAboutY()

Returns

FlatHexPoint

ScaleDown(int)

Scales this vector by the given amount.

public FlatHexPoint ScaleDown(int r)

Parameters

r int

Returns

FlatHexPoint

Examples

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

ScaleUp(int)

public FlatHexPoint ScaleUp(int r)

Parameters

r int

Returns

FlatHexPoint

Subtract(FlatHexPoint)

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

public FlatHexPoint Subtract(FlatHexPoint other)

Parameters

other FlatHexPoint

Returns

FlatHexPoint

ToCanonicalPosition(IEnumerable<FlatHexPoint>)

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

Parameters

shape IEnumerable<FlatHexPoint>

Returns

IEnumerable<FlatHexPoint>

ToString()

public override string ToString()

Returns

string

Translate(FlatHexPoint)

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

public FlatHexPoint Translate(FlatHexPoint translation)

Parameters

translation FlatHexPoint

Returns

FlatHexPoint

__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 +(FlatHexPoint, FlatHexPoint)

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

Parameters

point1 FlatHexPoint
point2 FlatHexPoint

Returns

FlatHexPoint

operator /(FlatHexPoint, FlatHexPoint)

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

Parameters

point1 FlatHexPoint
point2 FlatHexPoint

Returns

FlatHexPoint

operator /(FlatHexPoint, int)

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

Parameters

point FlatHexPoint
n int

Returns

FlatHexPoint

operator ==(FlatHexPoint, FlatHexPoint)

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

Parameters

point1 FlatHexPoint
point2 FlatHexPoint

Returns

bool

operator !=(FlatHexPoint, FlatHexPoint)

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

Parameters

point1 FlatHexPoint
point2 FlatHexPoint

Returns

bool

operator %(FlatHexPoint, FlatHexPoint)

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

Parameters

point1 FlatHexPoint
point2 FlatHexPoint

Returns

FlatHexPoint

operator *(FlatHexPoint, FlatHexPoint)

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

Parameters

point1 FlatHexPoint
point2 FlatHexPoint

Returns

FlatHexPoint

operator *(FlatHexPoint, int)

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

Parameters

point FlatHexPoint
n int

Returns

FlatHexPoint

operator -(FlatHexPoint, FlatHexPoint)

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

Parameters

point1 FlatHexPoint
point2 FlatHexPoint

Returns

FlatHexPoint

operator -(FlatHexPoint)

public static FlatHexPoint operator -(FlatHexPoint point)

Parameters

point FlatHexPoint

Returns

FlatHexPoint

operator +(FlatHexPoint)

public static FlatHexPoint operator +(FlatHexPoint point)

Parameters

point FlatHexPoint

Returns

FlatHexPoint