[Home] [Groups] - Message: [Prev in Group] [Next in Group]
9034: [MUD-Dev] Re: Hex-grid mapping
[Full Header] [Plain Text]
From: James Wilson <jwilson@rochester.rr.com>
Newsgroups: nu.kanga.list.mud-dev
Date: Tue, 1 Dec 1998 22:54:38 -0500
References: [1]
Organization: Kanga.Nu
On Tue, 01 Dec 1998, Jon Leonard wrote:
>On Tue, Dec 01, 1998 at 07:51:24PM -0500, James Wilson wrote:
>> this isn't a hex grid. It's a warped square grid. A hex grid has the useful
>> property that any cell has six neighbors, which is often a better fit for
>> tactical simulations than the square grid's four-with-four-diagonals neigbors.
>> For instance, diagonal motion makes a lot more sense in hexes than in squares
>> (assuming one move equals the traversal of one border).
>>
>> You can't tweak your equation to give them six neigbors, so don't try. (The
>> number of neighbors of each cell is a topological invariant, i.e. you can warp
>> space in any smooth way and each square will still have
>> four-with-four-diagonals neighbors.)
>
>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.
James