Battle analysis

 

The battlefield has a hexagon grid placed over the battlefield map to locate combat units and calculate distance, range and line of sight.

In order to analyze battles, the hexagon names are converted to a cartesian coordinate system, so that the mathematics of analytic geometry can be utilized. The cartesian coordinates pass thru the hexagon centers so unit counters can be placed on the map correctly. The interlaced hexagon grid is created by:

map

Note: the y-axis is scaled by a factor of √3

As the mouse moves, the interlaced hexagon grid conversions are displayed.

hexagon name ← (HexagonNameCalculator) → < hexagon point > ← (HexagonPointCalculator) → [screen pixels]

map

Programming Notes


HexagonPointCalculator

The HexagonPointCalculator converts mouse events into hexagon grid coordinates. The HexagonPointCalculator can also convert the hexagon point into screen coordinates so the unit counters can be placed on the screen at its hexagon location.

There are 3 coordinates that are used for battle analysis:.

1. HexagonPoint

As the mouse moves over the map, the movement into and out of hexagons will be calculated. The hexagon will be identified by the coordinate of the hexagon center. This coordinate will be called the Hexagon Point. This Hexagon Point is used for wargame calculations.

In this example, hexagon neighbors are at: (0,-4), (+2,-2), (+2,+2), (0,+4), (-2,+2), (-2,-2)

In this example, the x-axis and the y-axis are scaled by 2. The hexsides can now be identified by a point, so that terrain information can be stored in a database. This point is the average of the 2 surounding hexagon points. The hexside between <0101> and <0201> is ((4,8) + (6,10))/2 => (10,18)/2 => (5,9).

2. GridPoint

As the mouse moves over the map, The movement over a hexside is also calculated. The hexside is identified by the coordinate of the center of the hexside line and is called the Grid Point. If the mouse moves over the center of the hexagon, its coordinate is calculated as a connecting point between hexsides. The GridPoint can be either a hexside or a center that is connecting 2 hexsides.

3. VertexPoint

As the mouse moves over the map, The movement over a hexagon corner is also calculated. The corner is called the Vertex Point


HexagonName

The hexagon name is calculated with the HexagonNameCalculator and shown on the map. Wargames use a naming convention to label hexagons. The hexagon name can also be converted into a hexagon point. This hexagon point is used for geometry calculations.


Line of Sight

The hexagon grid provides methods to calculate line of sight, range, bearing.

line of sight, range, bearing for 90° turned map


Lines of Communication

lines of communication