# DDA Algorithm in Computer Graphics

DDA algorithm which scan and converts lines with acceptable approximation in sufficiently less time. Assume that a line is to be rasterized between given endpoints (x_{start}, y_{start}) and (x_{end}, y_{end}).

Now let us consider the equation of the line as:

**y=mx+c**

where m represents the slope of the line and c is the y intercept. This slope can be expressed as-

**m= (y**

_{end}– y_{start})/(x_{end}– y_{start})__DDA Algorithm:__

1. Read the line endpoints (x

2.

3. if(Δx≥ Δy) then

length=Δx

else

length=Δy

4. Select the raster unit,

5.

Sign function algorithm work in all quotient. It returns (-1,0) depending on whether it agreement is

< 0, =0, > 0 respectively.

6. Now plot the points i=1,

while(i≤ length)

{

Plot(integer(x), integer(y))

i=i+1

}

7. STOP

_{1}, y_{1}) and (x_{2}, y_{2})2.

**Δx=| x**_{2}– x_{1}|**Δy=| y**_{2}– y_{1}|3. if(Δx≥ Δy) then

length=Δx

else

length=Δy

4. Select the raster unit,

**Δx= (x**_{2}– x_{1})/length**Δy= (y**_{2}– y_{1})/length5.

**x= x+0.5*sign(Δx)****y= y+0.5*sign(Δy)**Sign function algorithm work in all quotient. It returns (-1,0) depending on whether it agreement is

< 0, =0, > 0 respectively.

6. Now plot the points i=1,

while(i≤ length)

{

Plot(integer(x), integer(y))

**x=x+Δx****y=y+Δy**i=i+1

}

7. STOP