Struct FlatHexPoint
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
Fields
EdgeDirections
public static readonly IEnumerable<FlatRhombPoint> EdgeDirections
Field Value
MainDirections
public static readonly IEnumerable<FlatHexPoint> MainDirections
Field Value
North
public static readonly FlatHexPoint North
Field Value
NorthEast
public static readonly FlatHexPoint NorthEast
Field Value
NorthWest
public static readonly FlatHexPoint NorthWest
Field Value
South
public static readonly FlatHexPoint South
Field Value
SouthEast
public static readonly FlatHexPoint SouthEast
Field Value
SouthWest
public static readonly FlatHexPoint SouthWest
Field Value
VertexDirections
public static readonly IEnumerable<PointyTriPoint> VertexDirections
Field Value
VertexFaceDirections
public static readonly IEnumerable<PointyTriPoint> VertexFaceDirections
Field Value
Zero
The zero point (0, 0).
public static readonly FlatHexPoint Zero
Field Value
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
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
SpliceIndex
For spliced grids, this is the index of the splice.
For Uniform grids, this is always 0.
public int SpliceIndex { get; }
Property Value
X
The x-coordinate of this point. This need to be in XML
public int X { get; }
Property Value
Y
The y-coordinate of this point.
public int Y { get; }
Property Value
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
Methods
DistanceFrom(FlatHexPoint)
The lattice distance from this point to the other.
public int DistanceFrom(FlatHexPoint other)
Parameters
otherFlatHexPoint
Returns
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
otherPointFlatHexPoint
Returns
Dot(FlatHexPoint)
[Version(1, 7, 0)]
public int Dot(FlatHexPoint other)
Parameters
otherFlatHexPoint
Returns
Equals(FlatHexPoint)
public bool Equals(FlatHexPoint other)
Parameters
otherFlatHexPoint
Returns
Equals(object)
public override bool Equals(object other)
Parameters
otherobject
Returns
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
Returns
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
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
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
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
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
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
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
GetColor5_5()
Since version 1.7
public int GetColor5_5()
Returns
GetColor6()
Since version 1.7
public int GetColor6()
Returns
GetEdgeAnchor()
public FlatRhombPoint GetEdgeAnchor()
Returns
GetEdges()
public IEnumerable<FlatRhombPoint> GetEdges()
Returns
GetHashCode()
public override int GetHashCode()
Returns
GetVertexAnchor()
public PointyTriPoint GetVertexAnchor()
Returns
GetVertexFaceAnchor()
public PointyTriPoint GetVertexFaceAnchor()
Returns
GetVertexFaces()
Get the coordinates of the faces that corresponds to this point treated as a vertex.
public IEnumerable<PointyTriPoint> GetVertexFaces()
Returns
GetVertices()
public IEnumerable<PointyTriPoint> GetVertices()
Returns
IsEquivalentUnderTransformsAndTranslation(IEnumerable<FlatHexPoint>, IEnumerable<FlatHexPoint>)
public static bool IsEquivalentUnderTransformsAndTranslation(IEnumerable<FlatHexPoint> shape1, IEnumerable<FlatHexPoint> shape2)
Parameters
shape1IEnumerable<FlatHexPoint>shape2IEnumerable<FlatHexPoint>
Returns
IsInNegativeHalfPlaneX(int)
public bool IsInNegativeHalfPlaneX(int x0)
Parameters
x0int
Returns
IsInNegativeHalfPlaneY(int)
public bool IsInNegativeHalfPlaneY(int y0)
Parameters
y0int
Returns
IsInNegativeHalfPlaneZ(int)
public bool IsInNegativeHalfPlaneZ(int z0)
Parameters
z0int
Returns
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
x0int
Returns
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
y0int
Returns
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
z0int
Returns
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
centerFlatHexPointradiusint
Returns
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
radiusint
Returns
IsInsidePolygon(int, int, int, int, int, int)
public bool IsInsidePolygon(int x0, int x1, int y0, int y1, int z0, int z1)
Parameters
Returns
IsInsideTriangle(int, int, int)
public bool IsInsideTriangle(int x0, int y0, int z0)
Parameters
Returns
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
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
otherPointFlatHexPoint
Returns
MoveBackBy(FlatHexPoint)
If a spliced vectors u and v has base vector B and index I
public FlatHexPoint MoveBackBy(FlatHexPoint translation)
Parameters
translationFlatHexPoint
Returns
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
translationFlatHexPoint
Returns
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
otherPointFlatHexPoint
Returns
Negate()
Returns a new point with the vector component negated.
public FlatHexPoint Negate()
Returns
Perp()
[Version(1, 10, 0)]
public FlatHexPoint Perp()
Returns
PerpDot(FlatHexPoint)
[Version(1, 7, 0)]
public int PerpDot(FlatHexPoint other)
Parameters
otherFlatHexPoint
Returns
PointFromVertexAnchor()
public PointyTriPoint PointFromVertexAnchor()
Returns
ReflectAboutX()
public FlatHexPoint ReflectAboutX()
Returns
ReflectAboutY()
public FlatHexPoint ReflectAboutY()
Returns
Rotate120()
public FlatHexPoint Rotate120()
Returns
Rotate120AndReflectAboutY()
public FlatHexPoint Rotate120AndReflectAboutY()
Returns
Rotate180()
public FlatHexPoint Rotate180()
Returns
Rotate180AndReflectAboutY()
public FlatHexPoint Rotate180AndReflectAboutY()
Returns
Rotate240()
public FlatHexPoint Rotate240()
Returns
Rotate240AndReflectAboutY()
public FlatHexPoint Rotate240AndReflectAboutY()
Returns
Rotate300()
public FlatHexPoint Rotate300()
Returns
Rotate300AndReflectAboutY()
public FlatHexPoint Rotate300AndReflectAboutY()
Returns
Rotate60()
public FlatHexPoint Rotate60()
Returns
Rotate60AndReflectAboutY()
public FlatHexPoint Rotate60AndReflectAboutY()
Returns
ScaleDown(int)
Scales this vector by the given amount.
public FlatHexPoint ScaleDown(int r)
Parameters
rint
Returns
Examples
v.ScaleUp(1)
v.ScaleUp(n) == v.ScaleUp(n - 1).Translate(v)
ScaleUp(int)
public FlatHexPoint ScaleUp(int r)
Parameters
rint
Returns
Subtract(FlatHexPoint)
Subtracts the other point from this point, and returns the result.
public FlatHexPoint Subtract(FlatHexPoint other)
Parameters
otherFlatHexPoint
Returns
ToCanonicalPosition(IEnumerable<FlatHexPoint>)
public static IEnumerable<FlatHexPoint> ToCanonicalPosition(IEnumerable<FlatHexPoint> shape)
Parameters
shapeIEnumerable<FlatHexPoint>
Returns
ToString()
public override string ToString()
Returns
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
translationFlatHexPoint
Returns
__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
Returns
Operators
operator +(FlatHexPoint, FlatHexPoint)
public static FlatHexPoint operator +(FlatHexPoint point1, FlatHexPoint point2)
Parameters
point1FlatHexPointpoint2FlatHexPoint
Returns
operator /(FlatHexPoint, FlatHexPoint)
public static FlatHexPoint operator /(FlatHexPoint point1, FlatHexPoint point2)
Parameters
point1FlatHexPointpoint2FlatHexPoint
Returns
operator /(FlatHexPoint, int)
public static FlatHexPoint operator /(FlatHexPoint point, int n)
Parameters
pointFlatHexPointnint
Returns
operator ==(FlatHexPoint, FlatHexPoint)
public static bool operator ==(FlatHexPoint point1, FlatHexPoint point2)
Parameters
point1FlatHexPointpoint2FlatHexPoint
Returns
operator !=(FlatHexPoint, FlatHexPoint)
public static bool operator !=(FlatHexPoint point1, FlatHexPoint point2)
Parameters
point1FlatHexPointpoint2FlatHexPoint
Returns
operator %(FlatHexPoint, FlatHexPoint)
public static FlatHexPoint operator %(FlatHexPoint point1, FlatHexPoint point2)
Parameters
point1FlatHexPointpoint2FlatHexPoint
Returns
operator *(FlatHexPoint, FlatHexPoint)
public static FlatHexPoint operator *(FlatHexPoint point1, FlatHexPoint point2)
Parameters
point1FlatHexPointpoint2FlatHexPoint
Returns
operator *(FlatHexPoint, int)
public static FlatHexPoint operator *(FlatHexPoint point, int n)
Parameters
pointFlatHexPointnint
Returns
operator -(FlatHexPoint, FlatHexPoint)
public static FlatHexPoint operator -(FlatHexPoint point1, FlatHexPoint point2)
Parameters
point1FlatHexPointpoint2FlatHexPoint
Returns
operator -(FlatHexPoint)
public static FlatHexPoint operator -(FlatHexPoint point)
Parameters
pointFlatHexPoint
Returns
operator +(FlatHexPoint)
public static FlatHexPoint operator +(FlatHexPoint point)
Parameters
pointFlatHexPoint