Sei sulla pagina 1di 3

#include <dos.

h>

#include <stdio.h>

#include <graphics.h>

#include <math.h>

void DDA (int x1,int y1,int x2,int y2){

float ax,ay,x,y,luz;

int i;

if(abs(x2-x1)>=abs(y2-y1))

luz=abs(x2-x1);

else

luz=abs(y2-y1);

ax=(x2-x1)/luz;

ay=(y2-y1)/luz;

x=(float)x1;

y=(float)y1;

i=1;

while(i<=luz)

putpixel((319+floor(x)),(239-floor(y)),9);
x=x+ax;

y=y+ay;

i=i+1;