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?

New contributor
Sarthak Sharma is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 2
    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 Sep 13 at 3:39
  • 1
    @PaulHK Any reservations to fleshing that out into a proper answer? – Christian Rau Sep 15 at 12:41

Your Answer

Sarthak Sharma is a new contributor. Be nice, and check out our Code of Conduct.
 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.