Bresenham's line algorithm is producing discretized line for given two points for purpose of plotting for example.
Like that:
I have to stress that I'm interested in positions, not a plot.
Wikipedia link I've provided includes an algorithm of course. I've just rewritten it thoughtlessly, I don't have time now or special need to work on neat implementation.
But if someone want to improve it (compile e.g.), got it already or know something more, I think this thread may be usefull for future visitors.
Very nice implementation can be found on rossetacode :P, according to that this algorithm should be built in so maybe someone knows how to get it.
Anyway, here's that code:
bresenham[{x1_, y1_}, {x2_, y2_}] :=
Module[{dx, xi, dy, yi, ai, bi, x, y, d},
If[x1 < x2, {xi, dx} = {1, x2 - x1};, {xi, dx} = {-1, x1 - x2};];
If[y1 < y2, {yi, dy} = {1, y2 - y1};, {yi, dy} = {-1, y1 - y2};];
x = x1; y = y1;
Sow[{x, y}];
If[dx > dy,
(ai = 2 (dy - dx); bi = 2 dy; d = bi - dx;
While[
If[d >= 0,
{x, y, d} += {xi, yi, ai},
{x, d} += {xi, bi}];
Sow[{x, y}];
x != x2])
,
(ai = 2 (dx - dy); bi = 2 dx; d = bi - dy;
While[
If[d >= 0,
{x, y, d} += {xi, yi, ai},
{y, d} += {yi, bi}];
Sow[{x, y}];
y != y2])
]] // Reap // Last // First