/// <summary> /// Uses a basic grid coordinate system to represent where a hex is in the complete grid. This gives a jaggered y. /// Since grids are offset between rows or columns, it's assumed that the center of (0,0) /// is at position (0,0). (0,1) diagonally up right to the the original. (0, 2) is in line with the original. /// This format assumes a TopPoint configuration /// </summary> /// <param name="coordinate"></param> /// <returns></returns> public Vector2 EuclidianPosition(DiscreteVector2 coordinate) { return(new Vector2( coordinate.X * HexHorizontalDistance + coordinate.Y % 2 * InnerRadius, coordinate.Y * HexVerticalDistance )); }
public void Works() { // Arrange DiscreteVector2 vec1 = new DiscreteVector2(1, 1); DiscreteVector2 vec2 = new DiscreteVector2(-1, 2); // Act DiscreteVector2 add = vec1 + vec2; DiscreteVector2 sub = vec2 - vec1; // Assert Assert.That(add == new DiscreteVector2(0, 3)); Assert.That(sub == new DiscreteVector2(-2, 1)); }
/// <summary> /// Construct a 2D array of Hexcoordinates to represent the grid /// </summary> /// <param name="dimensions"></param> public HexGrid2D(DiscreteVector2 dimensions) { Grid = SHexCoordinate.Grid2D(dimensions); }