/// <summary>Calculates a (canonical X or Y) grid-coordinate for a point, from the supplied 'picking' matrix.</summary> /// <param name="matrix">The 'picking-matrix' matrix</param> /// <param name="point">The screen point identifying the hex to be 'picked'.</param> /// <returns>A (canonical X or Y) grid coordinate of the 'picked' hex.</returns> static int GetCoordinate(HexMatrix matrix, HexPointF point) { var points = new HexPointF[] { point }; matrix.TransformPoints(points); return((int)Math.Floor((points[0].X + points[0].Y + 2F) / 3F)); }
/// <summary>Calculates a (canonical X or Y) grid-coordinate for a point, from the supplied 'picking' matrix.</summary> /// <param name="this"></param> /// <param name="matrix">The 'picking-matrix' matrix</param> /// <param name="point">The screen point identifying the hex to be 'picked'.</param> /// <returns>A (canonical X or Y) grid coordinate of the 'picked' hex.</returns> public static int GetCoordinate(this IHexgrid @this, HexMatrix matrix, HexPoint point) { var points = new HexPoint[] { point }; matrix.TransformPoints(points); return((int)Math.Floor((points[0].X + points[0].Y + 2F) / 3F)); }