This discussion reminds me of when I wanted (for God knows what reason) to know how far any given hex (as I happened to be working in the Marches) was from the navigational reference Reference. I actually wrote some PHP code to figure out how many hexes across and down one needed to get to reach reference (taking into account where Reference sat in its own sector).

I don't still have that handy or I'd share it for your amusement (even though it won't solve Jeff's problem) or if I do, its in an old computer that may or may not boot.

I also did a bit of a calculator that took two inputs: volume of air in a shipboard area and surface area of a hole punched through it to tell you how long you had until one or more thresholds of low air pressure would cause various symptoms like passing out or dying. I always felt a real space game needed that info.

That's probably either gone or on the same computer.

On Sun, Apr 12, 2020 at 8:00 AM Christopher Hilton <xxxxxx@vindaloo.com> wrote:
On Apr 11, 2020, at 10:51 PM, Christopher Sean Hilton <xxxxxx@vindaloo.com> wrote:
>
> On Fri, Mar 27, 2020 at 06:32:37PM -0400, Jeff Zeitlin wrote:
>> Given a standard Traveller subsector, with coordinates 0101 to 0810,
>> alternate columns staggered, what's the formula/algorithm to calculate the
>> jump distance between two hexes?
>>
>
> To start, there is a wealth of information on hex grids here:
>
> * [Hexagonal Grids](https://www.redblobgames.com/grids/hexagons/)
>
> Your question is best answered by the sections on Coordinate systems
> and distances:
>
> * [Hex Coordinate systems](https://www.redblobgames.com/grids/hexagons/#coordinates)
> * [Hex Distances](https://www.redblobgames.com/grids/hexagons/#distances)
>
> ----------------------------------------
>
> If you read the sections it will give you the algorithm. Here's some
> python that implements it.
>
> ```
> class Hex(object):
>
>    def __init__(self, hex_label):
>        self.hex_label = hex_label
>
>        ## Break a four digit hex label into it's x and y components
>
>        self.x, self.y = divmod(hex_label, 100)
>
>        ## Calculate an alternate (x, y) in this system two hexes
>        ## with the same y value will always be in a row.
>
>        self.alt_x = self.x
>        self.alt_y = self.y - (self.x // 2)
>

There’s a of-by-one bug here: The above line should read:

    `self.alt_y = self.y - ((self.x - 1) // 2)`

[ …snip… ]

Chris

      __o          "All I was trying to do was get home from work."
    _`\<,_           -Rosa Parks
___(*)/_(*)____.___o____..___..o...________ooO..._____________________
Christopher Sean Hilton                    [chris/at/vindaloo/dot/com]





-----
The Traveller Mailing List
Archives at http://archives.simplelists.com/tml
Report problems to xxxxxx@simplelists.com
To unsubscribe from this list please go to
http://www.simplelists.com/confirm.php?u=RDHE7iRpfwqlHvVvWBIhpJZsbTiD5NnL