Skip to content

Commit

Permalink
Added DDA with 3 points
Browse files Browse the repository at this point in the history
  • Loading branch information
suriya-1403 authored Mar 2, 2021
1 parent 62950b2 commit dc706c6
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions DDA3POINTS.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
void main(){

int gd = DETECT ,gm, i;
float x, y,dx,dy,steps,steps1,x3,y3,dx1,dy1;
int x0, x1, y0, y1,x2,y2;
initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");
x0 = 100 , y0 = 200, x1 = 400, y1 = 200,x2=600,y2=400;
dx = (float)(x1 - x0);
dy = (float)(y1 - y0);
dx1=(float)(x2-x1);
dy1=(float)(y2-y1);
if(dx>=dy)
{
steps = dx;
}
else
{
steps = dy;
}
dx = dx/steps;
dy = dy/steps;
x = x0;
y = y0;
i = 1;
while(i<= steps)
{
putpixel(x, y, WHITE);
x += dx;
y += dy;
i=i+1;
}
if(dx1>=dy1)
{
steps1 = dx1;
}
else
{
steps1 = dy1;
}
dx1 = dx1/steps1;
dy1 = dy1/steps1;
x3 = x1;
y3 = y1;
i = 1;
while(i<= steps1)
{
putpixel(x3, y3, BLUE);
x3 += dx1;
y3 += dy1;
i=i+1;
}
getch();
closegraph();
}


0 comments on commit dc706c6

Please sign in to comment.