1
$\begingroup$

In line drawing, bresenham's algorithm was explicitly derived for lines with slopes between 0 and 1 in the first octant from point P1 to point P2, where the x value of P1 is less than that for P2.

In the incremental version of this algorithm, once a pixel is drawn, we need to choose the next pixel to draw.

What are the choices? How do we go about choosing which pixel to draw next? (assuming a line width of 1 pixel)

$\endgroup$

1 Answer 1

1
$\begingroup$

Well, for the first octant you can either step EAST or NORTH-EAST. Depending on the distance to the actual line you choose the appropriate. In many integer implementations, this is done with regard to the sign of D.

$\endgroup$
3
  • $\begingroup$ But why doesn't it work for lines with slopes greater than 1 though? $\endgroup$
    – user9778
    Dec 7, 2018 at 23:26
  • $\begingroup$ How would we actually accomplish drawing these lines with slopes greater than 1 persay $\endgroup$
    – user9778
    Dec 7, 2018 at 23:29
  • $\begingroup$ The code only caters for the first octant by design. Well, this is easy to understand if you draw a line in the second octant. Here you will have to mirror the code in y=x, broadly speaking, or in other words step NE and N. This is the sign (dx) and sign (dy) you see in the implementations online. $\endgroup$
    – beyond
    Dec 9, 2018 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.