[MUD-Dev] Re: Hex-grid mapping
Nathan F Yospe
yospe at hawaii.edu
Wed Dec 2 11:44:25 New Zealand Daylight Time 1998
On Tue, 1 Dec 1998, James Wilson wrote:
:On Tue, 01 Dec 1998, Jon Leonard wrote:
:>On Tue, Dec 01, 1998 at 07:51:24PM -0500, James Wilson wrote:
:>Would you have been happier if I'd drawn my hexes like this?
:>
:> / \ / \ / \ / \
:> / \ / \ / \ / \
:> | 0,2 | 1,2 | 2,2 | 3,2 |
:> | | | | |
:> / \ / \ / \ / \ /
:> / \ / \ / \ / \ /
:> | 0,1 | 1,1 | 2,1 | 3,1 |
:> | | | | |
:> / \ / \ / \ / \ /
:> / \ / \ / \ / \ /
:>| 0,0 | 1,0 | 2,0 | 3,0 |
:>| | | | |
:> \ / \ / \ / \ /
:> \ / \ / \ / \ /
:>Those are really hexagons... And the six neighbors have the coordinate
:>deltas I specified. The fact that they don't look pretty in ASCII graphics
:>says little about the math.
:>That they're best stored in memory as a two dimensional array doesn't change
:>how the geometry works. Two of the "corner" diagonals are as adjacent as the
:>"sides", and the other two diagonals are farther away than with a square
:>geometry.
:>The underlying mathematics are that if you try to do coordinate geometry with
:>axes 60 degrees apart, the distance function changes to d=sqrt(x*x-x*y+y*y),
:>and the lattice points wind up being the centers of packed hexagons.
:nevertheless there are eight neighbors of each node, not six. perhaps he doesn't
:care about that.
There are six valid neighbors. sqrt(x^2 - xy + y^2) has six solutions of
value one - meaning six neighbors. I've used this myself, when working a
hex-mapped structure. Far simpler. And the guy who showed it to me is an
extremely good combinatoric mathematician. He's finishing a PhD in math,
at Stanford, no less, and when he showed me this, he couldn't resist the
urge to prove to me that it was, indeed, the *theoretical* best solution
to the problem, not just a nice one.
--
Nathan F. Yospe - Born in the year of the tiger, riding it forever after
University of Hawaii at Manoa, Dept of Physics, second year senior (joy)
(On Call) Associate Algorithm Developer, Textron Systems Corp, Maui Ops.
yospe#hawaii.edu http://www2.hawaii.edu/~yospe Non commercial email only
More information about the MUD-Dev
mailing list