Battle Analysis: Wargame Grid Calculations
The Wargame Grid Calculations provides information about the grid points on the Wargame Grid.
The Wargame Grid is a CARTESIAN COORDINATE SYSTEM.
Since the screen is also uses cartesian coordinates, unit locations can easily be calculated
and drawing with HTML5 canvas and SVG graphics is enabled. Drawing a hexagon map
The hexagons are refrenced by a point coordinate using the hexagon center location on the hexagon grid.
Hexsides can also be refrenced by a point coordinate.
Geometry can now be used for wargame calculations. Unit placement. Terrain data modeling. Line of Sight.Hexagon Name
The wargame map has labels on the hexagons to identify them.
The hexagon name is calculated from the hexagon point coordinate (x,y). Note: This hexagon name is NOT a coordinate.
divide the x by 4 then subtract 1 and divide the y by 8 (discard the remainder) then subtract 1
Movement is calculated by adjusting the coordinates:
Note: The movement to adjacent hexagons DOES NOT require a check to see if the column is even or odd.
Hexsides can also be refrenced by a grid coordinate.
The adjacent hexsides are calculated by adjusting the coordinates from the hexagon center point:
Zone of Control ZOC
Zone of Control is calculated using the unit's hexagon point. Although the unit is placed on the map, the location of the unit is an attribute of the unit.
ZocCalculator.prototype.unitIsZOC = function(index) { var isZOC = false; var los = new LineOfSight(this.map); var unitForce = this.force.getUnitForce(index); for (var i = 0; i < this.force.units.length; i++) { var force = this.force.getUnitForce(i); if(force != unitForce){ los.setOriginAndEndPoint(this.force.getUnitHexagonPoint(index), this.force.getUnitHexagonPoint(i)); if (los.getHexagonRange() == 1){ isZOC = true; break; } } return isZOC; }