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?

  • 2
    $\begingroup$ 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). $\endgroup$ – PaulHK Sep 13 '18 at 3:39
  • 1
    $\begingroup$ @PaulHK Any reservations to fleshing that out into a proper answer? $\endgroup$ – Christian Rau Sep 15 '18 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.