My code for implementation of DDA (Digital Differential Analyzer) algorithm is working good for drawing lines with slope less than 45o but fails in lines slope more than 45o.
It is behaving like a broken line for angles > 45o
Code
void dda(int x1,int y1,int x2,int y2)
{
float x,y,xinc,yinc,dx,dy;
int k,step;
dx = x2 - x1;
dy = y2 - y1;
step = abs(dx);
xinc = dx / step;
yinc = dy / step;
x = x1;
y = y1;
putpixel(x,y,63);
for(k=1;k<=step;k++)
{
x = x + xinc;
y = y + yinc;
putpixel(x,y,63);
}
}
Is this the demerit of DDA algorithm or there is any fault in my code, please help me to find out the cause that is making my program inefficient.
Thanks