swestrup: (Default)
[personal profile] swestrup
So, what would be the best way to write a DDA (Digital Differential Analyzer) for drawing lines on a Hex Grid? Note that I may want to play with various aspect ratios for the hexes, and/or allow a scene to be viewed from different angles (and not just from the obvious 6).
  1. Divide the circle into 6 hexants, and have a routine thats a standard DDA using the two of the six 'axis' directions that lie on either side of the line. This will generate hex coordinates, to later be converted to (x,y) when drawing on the hex grid.
  2. Do everything in (X,Y) coordinates, using a modified DDA that precomputes the differences due to the current orientation and aspect ratios.
  3. a DDA is not the right tool for this job.
I'm thinking of using this as part of a computer RPG where you might have, for example a 'range 6' attack, and as you move the mouse, it shows the path your shot might take as you target various squares. So, I want it snappy and responsive. Oh, and this may get written in Flash Actionscript, so just saying 'do it any old way, the computer is fast enough' may not really be true.

Date: 2007-02-26 03:56 pm (UTC)
From: (Anonymous)
(1) seems the simplest.

But what is DDA? Just the old algorithm to draw lines on a plotter that will only move its pen in eight directions? Or four? Or, in this case, six?

Date: 2007-02-26 04:16 pm (UTC)
From: [identity profile] sps.livejournal.com
(1). Of course the hexants in question are ±30° ones, not 0-60° ones. (Actually, it might be more reliable to use dodecants, just in case you ever find yourself dividing.)

Date: 2007-02-27 02:10 am (UTC)
From: [identity profile] sps.livejournal.com
Ah, I had understood that the task was to compute game mechanical lines, and maybe render them afterwards. If the task is to draw UI lines and maybe give them game mechanical interpretations afterwards, that's rather different!

January 2017

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 14th, 2026 08:00 am
Powered by Dreamwidth Studios