🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #332

Re: Line Of Sight For Hex Maps

#332
From: neil.a.kirby
Date: Sat, 11 Apr 1992 23:07
19 lines
1336 bytes
In article <wyman.702316368@granite> wyman@rtsg.mot.com (Mark S. Wyman) writes:
>Does anybody know of a good way to compute line of 
>sight for a hex based map.  The way I was thinking
>of implementing a hex map was skewing (shifting)
>every other row by one.  Not sure how to do LOS
>for this implementation.
>  
I use what I call rational numbering.  Even numbered columns carry even
numbered rows only.  Odd columns carry odd rows only.  That get's around
the problem of the ofset rows.  Then you take the difference in columns,
difference in rows (dc, dr).  The hex n steps between two other hexes is
hex1 + n/range * (dc,dr).  Linear interpolation.  Then force the result
into rational if it's not there already.

The HARD part is making sure that the algorithm is REFLEXIVE.  That is the
path from a to b is the same as b to a.  You will have to make some changes
to force it, but they are minor.

Neil Kirby
Technical Details
Message-ID: <1992Apr11.230700.12402@cbnews.cb.att.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!uwm.edu!linac!att!cbnews!nak
References: <wyman.702316368@granite>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!uwm.edu!linac!att!cbnews!nak
From: nak@cbnews.cb.att.com (neil.a.kirby)
Newsgroups: rec.games.programmer
Subject: Re: Line Of Sight For Hex Maps
Message-ID: <1992Apr11.230700.12402@cbnews.cb.att.com>
Date: 11 Apr 92 23:07:00 GMT
Article-I.D.: cbnews.1992Apr11.230700.12402
References: <wyman.702316368@granite>
Distribution: na
Organization: AT&T
Lines: 19