Menu

#2 Line Draw Bug

open
nobody
None
5
2003-04-16
2003-04-16
Anonymous
No

Hi guys,
just found a bug in the line draw function. I was
testing a routing algorithm and wondered why it
sometimes did not choose fairly obvious connections (I
almost went nuts trying to tweak parameters in my
algorithm to force it to take those : ) . Well, after
about an hour looking for a bug in my program I figured
it might be the line drawing itself. The problem is in
the Draw_Line.c file at the positions where the x1/y1
is switched with x2/y2. If you switch both points, you
got to switch the starting point of the drawing loop
from the old x1/y1 to the new x1/y1...

So to fix the bug, simply add

....
swap = x2;
x2 = x1;
x1 = swap;

//CHANGE BEGIN
x=x1;
y=y1;
//CHANGE END
}
if (dy < 0) {
....

and of course the same in the part if the ramp is going
into y direction. This assures that the while-loop
starts at the new x1/y1 and goes to the new x2/y2...
Cheers

Alex Klein
(AlexiKlein _AT_ gmx.net)

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.