Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bresenham question :)
#1
i have a feeling that this could be impossible.. ah well. here goes:

say you have a line x1-x2, y1-y2.

I want to figure out where to go next according to bresenham, one point per x and one point per y at a time {-1, 0, 1}, without going diagonally then straight. (nice and even..)

Is this possible? :/
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#2
Well, that is what is done in each bresenham loop. If the line is more vertical than horizontal, it will always advance 1 pixel vertically and 0 to 1 horizontally, and if it is more horizontal than vertical, it will always advance 1 pixel horizontally and 0 to 1 vertically, in each loop.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
rel's link doesn't work anymore. Sad
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#4
I have a bresenham line tut in my buffering tutorial Tongue
check it out http://www.venosoft.com/articles/buffers.html

See? I knew this article would be helpful to people! Smile
am an asshole. Get used to it.
Reply
#5
Code:
SUB bline (x, y, x2, y2)
dx = x2 - x
dy = y2 - y
IF dy < 0 THEN dy = -dy: yinc = -1 ELSE xinc = 1
IF dx < 0 THEN dx = -dx: xinc = -1 ELSE yinc = 1
IF dx > dy THEN
d1 = dy + dy - dx - dx
d = d1 + dx
d0 = d + dx
DO
IF x = x2 THEN EXIT DO
x = x + xinc
IF d < 0 THEN d = d + d0 ELSE d = d + d1: y = y + yinc
PSET (x, y)
LOOP
ELSE
d1 = dx + dx - dy - dy
d = d1 + dy
d0 = d + dy
DO
IF y = y2 THEN EXIT DO
y = y + yinc
IF d < 0 THEN d = d + d0 ELSE d = d + d1
x = x + xinc
PSET (x, y)
LOOP
END IF
END SUB

eDited.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#6
are implemented in the TC-Lib, downloadable from the Mandelbrot Dazibao. The full documentation is in french, I didn't have time for an english version, but you can try to Babelfish that, it could be fun :lol:
hink Global, Make Symp' All ! ®
[Image: Banner.gif]
Reply
#7
Quote:rel's link doesn't work anymore. Sad

Yeah, but why does my link have to do with Bresenham?
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#8
cuz you said you had it there somewhere.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#9
Rel, maybe it has something to do with RelLine, huh? :roll:
img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Reply
#10
QBrpgs.com>Utils>RelGFX. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)