alimentary
Posts: 142
Joined: 3/22/2010 Status: offline
|
quote:
ORIGINAL: Ian R quote:
ORIGINAL: EricTaylor Mathematically, if you want to determine the distance between two points on a coordinate plane, you use the distance formula. d = √(x2 - x1)^2 + (y2 - y1)^2. Luckily, we have the mouse-over instead of ...is that Pythagoras? That is indeed the Pythagorean theorem. As Ian R tried to say, it applies if you have cartesian coordinates on a Euclidean plane. The real pacific ocean is not a plane. AE pretends that it is. However, the really sticky bit is that AE is played on a hex grid. The coordinates look like they are Cartesian. But the AE space is not described by the Euclidean metric. It is more of a "taxicab metric" but adapted to a hex grid. AE distances are the number of moves from hex to adjacent hex that it would take to get from hex A to hex B. The hexes are lined up in horizontal rows. Each row has a Y coordinate. The rows are stacked with odd numbered rows half a hex farther east than even-numbered rows. This fact really throws a monkey wrench into everything unless you adopt a simple fix: Before sticking your numbers into the formula, increment the X coordinate on all odd numbered rows by 0.5. Now then, for generally north/south paths, the distance along the path is how many rows you've moved. Generally north/south paths are identified by the fact that the change in the X coordinate is less than or equal to half the change in Y coordinate: So: If |delta X| <= 0.5 * |delta Y| then distance = |delta Y| For generally east-west paths, the distance along the path is the the change in X coordinate plus 1/2 of the change in Y coordinate. If |delta X| >= 0.5 * |delta Y| then distance = |delta X| + 0.5 * |delta Y| Round fractions down. [On the diagonals where delta Y is half of delta X, both formulas naturally yield the same result] Let's try this out on the Johnston Isle to Colombo run. (164,112) => (29,48). Both of those are in even row numbers. So we have no X offset. Delta X = 164 - 29 = 135 Delta Y = 112 - 48 = 64 Delta X is greater than half of Delta Y so this is a generally east-west path. 135 + 64/2 = 135 + 32 = 167 Bingo!
< Message edited by alimentary -- 6/16/2020 6:56:40 PM >
|