On Maps, Grids, Objects, and Location - RPTools/maptool GitHub Wiki

Map References and Grids

A grid implements tesselated shapes to generalise locations into regions. While M.C. Escher patterns are cool, the only truly useful shapes are regular polygons, of which there are three;

  • Triangles,
  • Squares, and
  • Hexagons.

Most people have experience with square grids and the reference system of cartesian co-ordinates - Cartesian, Cartography, get it? - but it is only one of myriad methods. Sadly, while it is the most commonly understood it is also one of the most limiting and least useful. Squares have four axes of symmetry (of which we use two), trigons three and hexagons have twelve with 6 useful ones. You probably remember Polar Co-Ordinates from geometry but I'm not going there. Maptool currently utilises square and hexagonal grids and cartesian co-ordinates (until I can invoke massive changes in mind-sets). Go check out the interesting articles at Red Blob Games to find out how it should be done right.

Understand the difference between a reference and location. A grid reference defines an area, not a point. When you look at a map trying to find something at D4, D4 defines a bounded area within which lies the thing you are trying to find. The more precision you have in a reference the easier it is to find and the closer you get to a point, so D.15/4.26 would define an even smaller area and make the job easier. For map usage in the field, 6 and 8 figure grid references(3-4 numbers for East-West + 3-4 numbers for North-South) are good enough for telling people where something is.

An object on a map has a location. This location is a point, not an area. No matter how much you zoom in, the point does not grow, but the more precision we need in order to resolve it accurately. Now obviously an object is not a point, it's a thing, not an abstract geometric concept. So to line up the object with its point we need to use a point related to the object's shape. Computers, bless their little cotton socks, usually paint primitive objects like rectangles from one of the corners. This is annoying and goes against just about every mapping practise known to man. We want to place an object at a location not on its boundary. When in doubt, use the middle, the centre of a circle/bounded area/etc. To make life easier create the object so its origin lies at its centre. If you want to draw a square 120 pixels to the side, make it from the top-left x:-60, y:-60 to the bottom-right x:60, y:60. This way you can draw it anywhere and it doesn't need to be fiddled with to get it to line up right.

Token is in A1 but is located at x = 1.25, y = 1.0

image

Avoid integers. We don't need a lot of accuracy, but something defined in integers cannot straddle a line. Being one pixel out of place can be quite noticable. Allow things to be put where they belong at a sub-pixel level and let the computer do its antialiasing magic to make it look right. Also, integer maths might be fast but it introduces errors that accumulate to throw things out of whack. MapTool has a lot of integers that don't belong, when you find them, see if you can't bring them into last century and move them to floats or doubles.