0

# DDA line algorithm

Wiki User

2009-09-17 15:00:51

DDA Line Drawing Algorithm

Step 1:[Determine The Dx & Dy]

Dx=Xb-Xa

Dy=Yb-Ya

Step 2:[Determine Slope is Gentle or Sharp]

If |Dx|>|Dy| then

Gentle Slope

M=Dy/Dx

Set The Starting Point

If Dx>0 Then

C=CELING(Xb)

D=Yb+M*(C-Xb)

F=FLOOR(Xa)

R=FLOOR(D+0.5)

H=R-D+M

IF M>0 Then

Positive Gentle Slope

M1=M-1

Now Step Through The Columns

WHILE C<=F

C Programming Coding For DDA Algorithm
void linedda(int xa,int ya,int xb,int yb) {

int dx=xb-xa,dy=yb-ya,steps,k;
float xincrement,yincrement,x=xa,y=ya;

if(abs(dx)>abs(dy)) steps=abs(dx);
else steps=abs(dy);

xincrement=dx/(float)steps;
yincrement=dy/(float)steps;

putpixel(round(x),round(y),2)

for(k=0;kx+=xincrement;
y+=yincrement;
putpixel(round(x),round(y),2);
}
}
http://i.thiyagaraaj.com/articles/articles/dda-line-algorithm

Wiki User

2009-09-17 15:00:51
Study guides

20 cards

## What is a network server

➡️
See all cards
4.13
188 Reviews

Earn +20 pts
Q: DDA line algorithm