# What does the initial decision parameter mean in Bresenham's line drawing algorithm and how is it derived?

**URL:** <https://forum.kirupa.com/t/what-does-the-initial-decision-parameter-mean-in-bresenhams-line-drawing-algorithm-and-how-is-it-derived/676816>\
**Category:** programming\
**Created:** [August 14, 2025, 10:09am UTC](https://forum.kirupa.com/t/what-does-the-initial-decision-parameter-mean-in-bresenhams-line-drawing-algorithm-and-how-is-it-derived/676816 "2025-08-14T10:09:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oslon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/oslon/32/24631_2.png) [@oslon](https://forum.kirupa.com/u/oslon)\
**Post date:** [August 14, 2025, 10:09am UTC](https://forum.kirupa.com/t/what-does-the-initial-decision-parameter-mean-in-bresenhams-line-drawing-algorithm-and-how-is-it-derived/676816/1 "2025-08-14T10:09:41Z")

</div>

Consider line segment where m is between -1 and +1.

In order to determine pixels, we move along the x-direction in unit steps from the current position (x\_k,y\_k).

At each of these steps, we have to choose between the two y values y\_k and y\_(k+1).

Clearly, we would like to choose a pixel that is closer to the original line. Our choices of pixels are (x\_(k+1),y\_1) or (x\_(k+1),y\_(k+1)).

Denote:  
d\_upper=(y\_k+1)-y  
d\_lower=y-y\_k

We know

y=mx+b is the equation of a line.  
Now we calculate the difference between d\_lower and d\_upper.

d\_lower-d\_upper

= mx\_k+m+b-y\_k-y\_k-1+mx\_k+m+b  
=2m(x\_k+1)-2y\_k+2b-1

Substitute m with dy/dx.

d\_lower-d\_upper=2dy/dx\*(x\_k+1)-2y\_k+2b-1

dx(d\_lower-d\_upper)=2dyx\_k-2dxy\_k+2dy+dx(2b-1)  
= 2dyx\_k-2dxy\_k+c

Where c=2dy+dx(2b-1)

Let us denote dx(d\_lower-d\_upper) by p\_k, a decision parameter for the kth step.

At step k+1, the decision parameter is

p\_(k+1)=2dyx\_(k+1)-2dxy\_(k+1)+c

Subtracting p\_k from p\_(k+1), then substituting x\_(k+1)=x\_k+1 and rearranging we get

p\_(k+1)=p\_k+2dy-2dx(y\_(k+1)-y\_k)

**After this the author writes that the first decision parameter p\_0=2dy-dx. However he doesn’t provide much explanation for it.**

Can anyone help me derive the initial parameter?

---

<div class="post-metadata">

**Author:** ![oslon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/oslon/32/24631_2.png) [@oslon](https://forum.kirupa.com/u/oslon)\
**Post date:** [August 14, 2025, 10:14am UTC](https://forum.kirupa.com/t/what-does-the-initial-decision-parameter-mean-in-bresenhams-line-drawing-algorithm-and-how-is-it-derived/676816/2 "2025-08-14T10:14:30Z")

</div>

![image](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/2/7/274cc8f0f7c78df41d5d23d3a4f8875982a8fb36.png)

> **[rasterization.pdf](https://www.cs.ubc.ca/~tmm/courses/314-13/slides/rasterization.pdf)**
>
> 1526.25 KB

Some resources seem to derive by putting x, y values as above, but I didn’t get the meaning of this. That’s why I am asking this question.

Edit:

[![](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/7/e/7e342f991c90047444ecce6fc73a4fdd2ee40f0d.jpeg "CS401 - Deriving formula for Initial Decision Parameter (Bresenham's Line Drawing Algorithm)") ](https://www.youtube.com/watch?v=vvTMfJY0GCg)

This video derives the value but my confusion stands. What’s the meaning of p0? We are wanting to known when to plot the next pixel not the current one.

This is a bit intimidating I am afraid.

---

<div class="post-metadata">

**Author:** ![oslon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/oslon/32/24631_2.png) [@oslon](https://forum.kirupa.com/u/oslon)\
**Post date:** [August 18, 2025, 12:53pm UTC](https://forum.kirupa.com/t/what-does-the-initial-decision-parameter-mean-in-bresenhams-line-drawing-algorithm-and-how-is-it-derived/676816/3 "2025-08-18T12:53:19Z")

</div>

> **[Bresenham\_derivation.pdf](https://www.ercankoclar.com/wp-content/uploads/2016/12/Bresenham_derivation.pdf)**
>
> 22.63 KB

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [August 18, 2025, 3:14pm UTC](https://forum.kirupa.com/t/what-does-the-initial-decision-parameter-mean-in-bresenhams-line-drawing-algorithm-and-how-is-it-derived/676816/4 "2025-08-18T15:14:03Z")

</div>

A lot of this has to do with how drawing works on the canvas. When drawing, there is no prior memory of where the pen currently is. Each draw operation assumes you are starting from the (0,0) point or wherever the default starting location happens to be.

The p0 is the starting point and p1 would be the ending point. This article may help shed some light here: [Canvas Drawing Basics | KIRUPA](https://www.kirupa.com/canvas/drawing_basics_canvas.htm)
