#### Archived

This topic is now archived and is closed to further replies.

# Understanding Bresenham's Algorithm

This topic is 6023 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I posted this in the math forum, but I''m not totally sure if it really related to math, so I''ll post it in this forum, since it''s an topic related to programming. http://graphics.cs.ucdavis.edu/GraphicsNotes/Bresenhams-Algorithm/Bresenhams-Algorithm.html I have gone there to learn about Bresenham''s Algorithm. I think I understand the algorithm, but I''m not sure I understand the order of operation in which things are performed. For instance, the first pixel, or starting point of the line is colored, that I have down, then I''m not sure what is next. Do you increment E(error) then check to see if( E > 0). If thats true, then you increment the y coordinate by 1? Or do you first increment E, then increment the x coordinate, then check to see if(E > 0) and if thats true, you then increment the y coordianate by 1?

##### Share on other sites
COME ON! Somebody out there has to know this algorithm!!!!

##### Share on other sites
First you determine the deltas (change) in x and y from the start point to the end point of the line. Then you determine the Driving Axis, which is the greater of the two absolute deltas from the previous step. Then you determine the slop of the line, which is delta Y over delta X, lets call that M. E is set to M - 1. Then when you start drawing the driving axis is incremented by one each time, and E is incremented by M, if E ever becomes greater than 0 then you increment the other axis by 1 and subtract 1 from E.

------------
- outRider -

1. 1
2. 2
Rutin
22
3. 3
4. 4
frob
18
5. 5

• 33
• 13
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
632565
• Total Posts
3007106

×