<p>I was studying the DDA Algorithm and learnt that initially we calculate both the <strong>x-difference</strong> and the <strong>y-difference</strong> between the start and the end points of the given line, and <strong>if dx > dy</strong>, we choose <strong>xIncrement as 1</strong> and get the successive y-values. The <strong>opposite happens when dy > dx</strong>, in that case we choose yIncrement as 1 and <strong>get the successive x-values</strong> using the slope of the line. Why do we do that?</p>

<p>Is it just that if there are more number of steps, then we get higher accuracy and more definition in our line that is drawn on a raster display?</p>

CC BY-SA 4.0
2018-09-13T03:39:52.903Z
It's because it draws a line using 1 pixel per column going from left to right, which is true for lines that are below 45 degress with respect to the horizontal axis (dx > dy). If you imagine a line steeper than 45 degrees then you can no longer draw the line using 1 pixel per column, however the DDA algorithm deals this case and swaps x/y around when dy > dx (line is mostly vertical).
PaulHK
CC BY-SA 4.0
2018-09-15T12:41:35.503Z
@PaulHK Any reservations to fleshing that out into a proper answer?
Christian Rau
<algorithm>
Why the interval for which there are more number of steps is chosen while implementing DDA Algorithm?
Sarthak Sharma
# Why the interval for which there are more number of steps is chosen while implementing DDA Algorithm?

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

I was studying the DDA Algorithm and learnt that initially we calculate both the **x-difference** and the **y-difference** between the start and the end points of the given line, and **if dx > dy**, we choose **xIncrement as 1** and get the successive y-values. The **opposite happens when dy > dx**, in that case we choose yIncrement as 1 and **get the successive x-values** using the slope of the line. Why do we do that?

Is it just that if there are more number of steps, then we get higher accuracy and more definition in our line that is drawn on a raster display?

**Tags:** algorithm

> **Comments:**
> **username_1**: It's because it draws a line using 1 pixel per column going from left to right, which is true for lines that are below 45 degress with respect to the horizontal axis (dx > dy). If you imagine a line steeper than 45 degrees then you can no longer draw the line using 1 pixel per column, however the DDA algorithm deals this case and swaps x/y around when dy > dx (line is mostly vertical).  
> **username_2**: @username_1 Any reservations to fleshing that out into a proper answer?  

---

## 0 answers

