/// <summary> /// Returns the quotient of two <see cref="IHexCoordinate" />. /// </summary> /// <param name="left"><see cref="IHexCoordinate" />.</param> /// <param name="right"><see cref="IHexCoordinate" />.</param> /// <returns>Quotient of <paramref name="left" /> and <paramref name="right" />.</returns> /// <exception cref="ArgumentNullException"><paramref name="left" /> is null.</exception> public static IHexCoordinate Divide(this IHexCoordinate left, int right) { if (left == null) { throw new ArgumentNullException("left"); } return(HexCoordinates.Axial(left.Q / right, left.R / right)); }
private static IHexCoordinate OffsetDistance(this IAxialCoordinate coordinate, int qOffset, int rOffset, int distance) { if (coordinate == null) { throw new ArgumentNullException("coordinate"); } qOffset *= distance; rOffset *= distance; return(HexCoordinates.Axial(coordinate.Q + qOffset, coordinate.R + rOffset)); }
/// <summary> /// Returns the difference of two <see cref="IHexCoordinate" />. /// </summary> /// <param name="left"><see cref="IHexCoordinate" />.</param> /// <param name="right"><see cref="IHexCoordinate" />.</param> /// <returns>Difference of <paramref name="left" /> and <paramref name="right" />.</returns> /// <exception cref="ArgumentNullException"><paramref name="left" /> or <paramref name="right" /> is null.</exception> public static IHexCoordinate Subtract(this IHexCoordinate left, IHexCoordinate right) { if (left == null) { throw new ArgumentNullException("left"); } if (right == null) { throw new ArgumentNullException("right"); } return(HexCoordinates.Axial(left.Q - right.Q, left.R - right.R)); }
/// <summary> /// Initializes a new unit <see cref="IHexCoordinate" /> with given <paramref name="direction" /> and /// <paramref name="distance" />. /// </summary> /// <param name="direction">Direction from (0, 0).</param> /// <param name="distance">Distance from (0, 0).</param> /// <returns>Unit <see cref="IHexCoordinate" />.</returns> /// <exception cref="ArgumentOutOfRangeException"> /// <para><paramref name="distance" /> < 0.</para> /// <para><paramref name="direction" /> out of range.</para> /// </exception> public static IHexCoordinate Distance(this HexDirection direction, int distance) { return(HexCoordinates.Axial(0, 0).Neighbor(direction, distance)); }