0% found this document useful (0 votes)
2K views

DDA Algorithm

The DDA (Digital Differential Analyzer) algorithm is used to draw lines on a digital display. It works by calculating the change in x or y per step using slope equations, and rounding the result to the nearest integer pixel position. There are two cases - for positive slope it calculates successive y values, and for negative slope it calculates successive x values. It iterates through these calculations from start to end point to determine all points along the line.

Uploaded by

jayanthikrishnan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

DDA Algorithm

The DDA (Digital Differential Analyzer) algorithm is used to draw lines on a digital display. It works by calculating the change in x or y per step using slope equations, and rounding the result to the nearest integer pixel position. There are two cases - for positive slope it calculates successive y values, and for negative slope it calculates successive x values. It iterates through these calculations from start to end point to determine all points along the line.

Uploaded by

jayanthikrishnan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

DDA Algorithm (Digital Differential Analyzer)

• It is a scan-conversion line algorithm Based on calculating either Δy or Δx using the


above equations.

• We sample the line at unit intervals in one coordinate and determine corresponding
integer values nearest the line path for the other coordinate.

• There are two cases:

– Positive slop

– Negative slop

DDA- Line with positive Slope

If m ≤ 1 then take Δx = 1

• Compute successive y by

yk+1 = yk + m (1)

• Subscript k takes integer values starting from 1, for the first point, and increases by
1 until the final end point is reached.

• Since 0.0 < m ≤ 1.0, the calculated y values must be rounded to the nearest integer
pixel position.

• If m > 1, reverse the role of x and y and take Δy = 1, calculate successive x from

xk+1 = xk + 1/m (2)

• In this case, each computed x value is rounded to the nearest integer pixel position.

• The above equations are based on the assumption that lines are to be processed
from left endpoint to right endpoint.

• In case the line is processed from Right endpoint to Left endpoint, then

Δx = −1, yk+1 = yk − m for m ≤ 1 (3)

or

Δy = −1, xk+1 = xk −1/m for m > 1 (4)

DDA- Line with negative Slope

• If m < 1,

– use(1) [provided line is calculated from left to right] and

– use(3) [provided line is calculated from right to left].


• If m ≥ 1

– use (2) or (4).

Advantages of DDA Algorithm

1. It is the simplest algorithm

2. It is a is a faster method for calculating pixel positions

Disadvantages of DDA Algorithm

1. Floating point arithmetic in DDA algorithm is still time-consuming

2. End point accuracy is poor

Example: Consider the line from (0,0) to (4,6)

1. xa=0, ya =0 and xb=4 yb=6

2. dx=xb-xa = 4-0 = 4 and dy=yb-ya=6-0= 6

3. x=0 and y=0


4. 4 > 6 (false) so, steps=6

5. Calculate xIncrement = dx/steps = 4 / 6 = 0.66 and yIncrement = dy/steps =6/6=1

6. Setpixel(x,y) = Setpixel(0,0) (Starting Pixel Position)

7. Iterate the calculation for xIncrement and yIncrement for steps(6) number of times.

Tabulation of the each iteration

You might also like