Question: Use this program to implement DDA Algorithm void linebre (int xa, int ya, int xb, int yb) { int dx = abs (xa-xb), dy =

Use this program to implement DDA Algorithm

void linebre (int xa, int ya, int xb, int yb)

{ int dx = abs (xa-xb), dy = abs (ya-yb);

int p=2xdy-dx

int twody=2*dy, twodydx=2x(dy-dx)

int x,y, xEnd;

//determine which point to use as start

//which as end

if(xa>xb)

{

x=xb

y-yb

xEnd=xa;

}

else

{

x=xa;

y=ya;

xEnd=xb;

}

set pixel (x,y)

while (x

{

x++;

if (p<0)

p+= twody;

else

{

y++;

p+ = twodydx;

else

{

y++;

p+ = twodydx;

}

setpixel (x,y);

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!