Jump to content
  • Advertisement


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

Brian Jones

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.

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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 -

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!