Struct PointyHexPoint
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
Fields
East
public static readonly PointyHexPoint East
Field Value
EdgeDirections
public static readonly IEnumerable<PointyRhombPoint> EdgeDirections
Field Value
MainDirections
public static readonly IEnumerable<PointyHexPoint> MainDirections
Field Value
NorthEast
public static readonly PointyHexPoint NorthEast
Field Value
NorthWest
public static readonly PointyHexPoint NorthWest
Field Value
SouthEast
public static readonly PointyHexPoint SouthEast
Field Value
SouthWest
public static readonly PointyHexPoint SouthWest
Field Value
VertexDirections
public static readonly IEnumerable<FlatTriPoint> VertexDirections
Field Value
VertexFaceDirections
public static readonly IEnumerable<FlatTriPoint> VertexFaceDirections
Field Value
West
public static readonly PointyHexPoint West
Field Value
Zero
The zero point (0, 0).
public static readonly PointyHexPoint 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 PointyHexPoint 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 redundant, 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(PointyHexPoint)
The lattice distance from this point to the other.
public int DistanceFrom(PointyHexPoint other)
Parameters
otherPointyHexPoint
Returns
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
otherPointPointyHexPoint
Returns
Dot(PointyHexPoint)
[Version(1, 7, 0)]
public int Dot(PointyHexPoint other)
Parameters
otherPointyHexPoint
Returns
Equals(PointyHexPoint)
public bool Equals(PointyHexPoint other)
Parameters
otherPointyHexPoint
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 PointyRhombPoint GetEdgeAnchor()
Returns
GetEdges()
public IEnumerable<PointyRhombPoint> GetEdges()
Returns
GetHashCode()
public override int GetHashCode()
Returns
GetNeighbors()
public IEnumerable<PointyHexPoint> GetNeighbors()
Returns
GetVertexAnchor()
public FlatTriPoint GetVertexAnchor()
Returns
GetVertexFaceAnchor()
public FlatTriPoint GetVertexFaceAnchor()
Returns
GetVertexFaces()
Get the coordinates of the faces that corresponds to this point treated as a vertex.
public IEnumerable<FlatTriPoint> GetVertexFaces()
Returns
GetVertices()
public IEnumerable<FlatTriPoint> GetVertices()
Returns
IsEquivalentUnderTransformsAndTranslation(IEnumerable<PointyHexPoint>, IEnumerable<PointyHexPoint>)
public static bool IsEquivalentUnderTransformsAndTranslation(IEnumerable<PointyHexPoint> shape1, IEnumerable<PointyHexPoint> shape2)
Parameters
shape1IEnumerable<PointyHexPoint>shape2IEnumerable<PointyHexPoint>
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(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
centerPointyHexPointradiusint
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(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
otherPointPointyHexPoint
Returns
MoveBackBy(PointyHexPoint)
If a spliced vectors u and v has base vector B and index I
public PointyHexPoint MoveBackBy(PointyHexPoint translation)
Parameters
translationPointyHexPoint
Returns
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
translationPointyHexPoint
Returns
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
otherPointPointyHexPoint
Returns
Negate()
Returns a new point with the vector component negated.
public PointyHexPoint Negate()
Returns
Perp()
[Version(1, 10, 0)]
public PointyHexPoint Perp()
Returns
PerpDot(PointyHexPoint)
[Version(1, 7, 0)]
public int PerpDot(PointyHexPoint other)
Parameters
otherPointyHexPoint
Returns
PointFromVertexAnchor()
public FlatTriPoint PointFromVertexAnchor()
Returns
ReflectAboutX()
public PointyHexPoint ReflectAboutX()
Returns
ReflectAboutY()
public PointyHexPoint ReflectAboutY()
Returns
Rotate120()
public PointyHexPoint Rotate120()
Returns
Rotate120AndReflectAboutY()
public PointyHexPoint Rotate120AndReflectAboutY()
Returns
Rotate180()
public PointyHexPoint Rotate180()
Returns
Rotate180AndReflectAboutY()
public PointyHexPoint Rotate180AndReflectAboutY()
Returns
Rotate240()
public PointyHexPoint Rotate240()
Returns
Rotate240AndReflectAboutY()
public PointyHexPoint Rotate240AndReflectAboutY()
Returns
Rotate300()
public PointyHexPoint Rotate300()
Returns
Rotate300AndReflectAboutY()
public PointyHexPoint Rotate300AndReflectAboutY()
Returns
Rotate60()
public PointyHexPoint Rotate60()
Returns
Rotate60AndReflectAboutY()
public PointyHexPoint Rotate60AndReflectAboutY()
Returns
ScaleDown(int)
Scales this vector by the given amount.
public PointyHexPoint ScaleDown(int r)
Parameters
rint
Returns
Examples
v.ScaleUp(1)
v.ScaleUp(n) == v.ScaleUp(n - 1).Translate(v)
ScaleUp(int)
public PointyHexPoint ScaleUp(int r)
Parameters
rint
Returns
Subtract(PointyHexPoint)
Subtracts the other point from this point, and returns the result.
public PointyHexPoint Subtract(PointyHexPoint other)
Parameters
otherPointyHexPoint
Returns
ToCanonicalPosition(IEnumerable<PointyHexPoint>)
public static IEnumerable<PointyHexPoint> ToCanonicalPosition(IEnumerable<PointyHexPoint> shape)
Parameters
shapeIEnumerable<PointyHexPoint>
Returns
ToString()
public override string ToString()
Returns
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
translationPointyHexPoint
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 +(PointyHexPoint, PointyHexPoint)
public static PointyHexPoint operator +(PointyHexPoint point1, PointyHexPoint point2)
Parameters
point1PointyHexPointpoint2PointyHexPoint
Returns
operator /(PointyHexPoint, PointyHexPoint)
public static PointyHexPoint operator /(PointyHexPoint point1, PointyHexPoint point2)
Parameters
point1PointyHexPointpoint2PointyHexPoint
Returns
operator /(PointyHexPoint, int)
public static PointyHexPoint operator /(PointyHexPoint point, int n)
Parameters
pointPointyHexPointnint
Returns
operator ==(PointyHexPoint, PointyHexPoint)
public static bool operator ==(PointyHexPoint point1, PointyHexPoint point2)
Parameters
point1PointyHexPointpoint2PointyHexPoint
Returns
operator !=(PointyHexPoint, PointyHexPoint)
public static bool operator !=(PointyHexPoint point1, PointyHexPoint point2)
Parameters
point1PointyHexPointpoint2PointyHexPoint
Returns
operator %(PointyHexPoint, PointyHexPoint)
public static PointyHexPoint operator %(PointyHexPoint point1, PointyHexPoint point2)
Parameters
point1PointyHexPointpoint2PointyHexPoint
Returns
operator *(PointyHexPoint, PointyHexPoint)
public static PointyHexPoint operator *(PointyHexPoint point1, PointyHexPoint point2)
Parameters
point1PointyHexPointpoint2PointyHexPoint
Returns
operator *(PointyHexPoint, int)
public static PointyHexPoint operator *(PointyHexPoint point, int n)
Parameters
pointPointyHexPointnint
Returns
operator -(PointyHexPoint, PointyHexPoint)
public static PointyHexPoint operator -(PointyHexPoint point1, PointyHexPoint point2)
Parameters
point1PointyHexPointpoint2PointyHexPoint
Returns
operator -(PointyHexPoint)
public static PointyHexPoint operator -(PointyHexPoint point)
Parameters
pointPointyHexPoint
Returns
operator +(PointyHexPoint)
public static PointyHexPoint operator +(PointyHexPoint point)
Parameters
pointPointyHexPoint