witpqs
Posts: 26087
Joined: 10/4/2004 From: Argleton Status: offline
|
quote:
ORIGINAL: n01487477 Base screen not complete yet ... have a bit of a chicken and the egg situation I'm still working out with HQ ranged Naval support (NS). Using witqs range calculations from his OpenOffice util etc and integration might take a little while. The Base figures you see below are just at base (so far). When I was trying to solve that formula I went searching the net for examples. I found some that did not work for WITP/AE, then found one post that had a variation in it to account for the AE hex numbering scheme. Most of the formulae you will find by searching are for the simpler example where the X and Y axes are along hex rows. But in AE (and presumably plenty of games), only 1 axes is along a hex row, while the other is directly perpendicular to that row (and thereby does not go directly along any hex row). I kept getting very close to solving it myself but did not quite get there, then I found the post below. I am pasting it in for your reference, because it actually contains a code snippet. I had to adapt the code snippet for a spreadsheet. No sense in you having to reverse that process - deja vu all over again! I am inserting a couple of notes in bold to make certain I am being clear about the X and Y axes implications. quote:
I prefer a numbering where both x and y correspond to straight lines of hexes, i.e., letting x increase (with constant y) by going right and y increase (with constant x) by going 60 degrees down from right (assuming (0,0) is top left corner). This way, if you move in one of the three "natural" directions, you either have constant x, constant y or constant (x+y). That makes calculation of distances etc. easier, as you don't have to sepcial-case on odd and even rows. I assume you know the hex coordinates and want to find the distance in number of hexes while moving across edges. If you had used the alternative numbering I described above, the distance is calculated as follows: The following could be used if the AE hexes were numbered differently (meaning X and Y each along a hex row). mydistance((x1,y1), (x2,y2)) = if x1>x2 then mydistance((x2,y2), (x1,y1)) else if y2>=y1 then x2-x1 + y2-y1 else max(x2-x1, y1-y2) With the numbering shown on the webpage you cited, you can calculate distance as follows: The following adaptation to the above code is required to account for the way the AE hexes are numbered. yourdistance((x1,y1),(x2,y2)) = mydistance((x1 - y1 `div` 2,y1), (x2 - y2 `div` 2,y2)) i.e., convert to the simpler coordinate system and calculate distance in that. You convert by subtracting half the y coordinate (rounded down) from the x coordinate.
|