<p>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 <a href="https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm" rel="nofollow noreferrer">implementations</a>, this is done with regard to the sign of D.</p>

CC BY-SA 4.0
2018-12-07T23:26:22.433Z
But why doesn't it work for lines with slopes greater than 1 though?
user9778
CC BY-SA 4.0
2018-12-07T23:29:02.087Z
How would we actually accomplish drawing these lines with slopes greater than 1 persay
user9778
CC BY-SA 4.0
2018-12-09T00:26:10.160Z
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.
beyond
CC BY-SA 4.0
2018-12-07T08:07:09.833Z
2018-12-07T08:07:09.833Z
beyond
<p>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.</p>

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

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

<algorithm><line-drawing>
Bresenham's algorithm next pixel?
user9778
# Bresenham's algorithm next pixel?

(Asked by: username_0 on 2018-12-07)

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)

**Tags:** algorithm, line-drawing


---

## 1 answers

### Answer by username_1 on 2018-12-07. Score: 1 | Accepted answer

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](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm), this is done with regard to the sign of D.

> **Comments:**
> **username_0**: But why doesn't it work for lines with slopes greater than 1 though?  
> **username_0**: How would we actually accomplish drawing these lines with slopes greater than 1 persay  
> **username_1**: 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.  

---

